There's a straightforward abstract answer that you may not like, but, because it clarifies your question and explains a uniform way to answer similar questions, I'll sketch it here. First, consider a simpler problem of this kind: Suppose that one wants to describe the group of isometries of a Riemannian metric $\rho$ on a Riemannian $n$-manifold $M$. By definition, a mapping $f:M\to M$ is an isometry if and only if $f^*(\rho)-\rho =0$. Thus, one defines the operator $T(f) = f^*(\rho)-\rho$, which takes smooth maps $f:M\to M$ to sections of $S^2(T^*M)$ and notes that $T(f)=0$ if and only if $f$ is an isometry. Moreover, if $g:M\to M$ is an isometry and $f:M\to M$ is any mapping, then $$ T(g\circ f) = (g\circ f)^*(\rho)-\rho = f^*\bigl(g^*(\rho)\bigr)-\rho = f^*(\rho)-\rho = T(f). $$ Thus, the differential operator $T$ satisfies the conditions that you want for detecting the group of isometries of $\rho$. Now, consider the slightly more subtle case of affine transformations: Let $(M,\alpha)$ be a manifold endowed with a (torsion-free) affine connection $\alpha$. Now, torsion-free affine connections, unlike Riemannian metrics, are not given by specifying a section of a natural *vector* bundle over $M$. Instead, there is a natural *affine* bundle over $M$, call it $\mathsf{A}(M)$, that is modeled on the natural vector bundle $TM\otimes S^2(T^*M)$ and whose sections define the torsion-free affine connections on $M$. (The bundle $\mathsf{A}(M)$ is natural in the sense that, if $f:M_1\to M_2$ is any diffeomorphism, there is canonically induced a bundle isomorphism $\mathsf{A}(f):\mathsf{A}(M_2)\to \mathsf{A}(M_1)$ such that, if $\alpha$ is a section of $\mathsf{A}(M_2)$ (and hence a torsion-free affine structure on $M_2$), then $\mathsf{A}(f)\circ\alpha$ is a section of $\mathsf{A}(M_1)$ that represents the connection $\alpha$ pulled back via the diffeomorphism $f$. We also have $\mathsf{A}(g\circ f) = \mathsf{A}(f)\circ \mathsf{A}(g)$, as the canonical map is contravariant. Now, the answer to the problem of characterizing the symmetries of an affine structure $\alpha$ on $M$ has a reasonable answer: Simply set $$ T(f) = \mathsf{A}(f)\circ\alpha - \alpha, $$ and this will have all the properties that you want. Note that, because $\mathsf{A}(M)$ is modeled on the vector bundle $TM\otimes S^2(T^*M)$, the nonlinear differential operator $T$ takes values in the *vector* bundle $TM\otimes S^2(T^*M)$. When one unravels this for $M=\mathbb{R}^n$ and $\alpha = \alpha_0$, the standard flat affine structure on $\mathbb{R}^n$, by writing everything in coordinates, one obtains the expression you wrote down above in local coordinates. Finally, let's come to the case of a manifold of dimension $n>1$ (the case $n=1$ is different) with a (torsion-free) *projective* structure $(M,\pi)$, where, now, $\pi$ is a section of a certain natural affine bundle $\mathsf{P}(M)$ that is modeled on the the vector bundle $\mathsf{Q}(M)$ that fits into the natural exact sequence $$ 0\longrightarrow T^*M\longrightarrow TM\otimes S^2(T^*M)\longrightarrow \mathsf{Q}(M)\longrightarrow 0. $$ (Note that $\mathsf{Q}(M)$ is a vector bundle of rank $\tfrac12n(n{-}1)(n{+}2)$. The fact that this rank is $0$ when $n=1$ is why the case $n=1$ is different. Indeed, in dimension $1$ every $2$-jet of a diffeomorphism is the $2$-jet of a projective transformation, so one has to go to $3$-jets to get an equation.) Again, if $f:M\to M$ is any diffeomorphism, there is a canonically induced bundle mapping $\mathsf{P}(f):\mathsf{P}(M)\to\mathsf{P}(M)$, and these bundle maps satisfy $\mathsf{P}(g\circ f) = \mathsf{P}(f)\circ \mathsf{P}(g)$. Now, again, the solution to the problem of characterizing the diffeomorphisms $f:M\to M$ that preserve a given (torsion-free) projective structure $\pi$ is to define $$ T(f) = \mathsf{P}(f)\circ\pi - \pi, $$ and this operator $T$, taking a diffeomorphism $f:M\to M$ to a section of $\mathsf{Q}(M)$ (since the difference of two sections of $\mathsf{P}(M)$ lies in $\mathsf{Q}(M)$), has all the desired properties. When one writes this out in local coordinates, this gives the (second-order) partial differential equations that characterize projective transformations. Essentially, this approach goes back to Sophus Lie in the 19th century, but it was considerably clarified by the work of Élie Cartan early in the 20th century, in his works on what we would now call Lie pseudo-groups of transformations. Indeed, Cartan described how one constructs all of these 'natural' bundles, $T^*M$, $TM$, $\mathsf{A}(M)$, $\mathsf{P}(M)$, etc. as what he called 'prolongations' of the diffeomorphism group of $M$. In principle, one can compute all the prolongations of any desired order, but mostly one is interested in those of the first and second order.