I have read some parts of "A first course in Modular forms" to understand the process of associating a Galois representation to modular forms. In the book it is done only for weight 2 but I didn't understand what will go wrong if we consider any other weight.
My background is -- general knowledge about modular forms and classical algebraic geometry, chapters 1, 2, 5, 7, 8, and 9 of "A first course in Modular forms".
I have no idea about what an Étale cohomology (or cohomology in general) is, or about any concepts from representation theory. And, I just thought of the Abelian variety used in section 9.5 as just some quotient of Picard group of modular curve $X_1(N)$ as I felt its role was not very important there.
Here's a slightly ahistorical take.
The short answer is that we get lucky with weight $2$ modular forms, that their Galois representations are relatively easy to construct.
As a general rule, constructing Galois representations to geometric objects (i.e. smooth projective varieties, elliptic curves, etc) is easy: just use étale cohomology (as a black box if need be), or if your variety is a curve (e.g. an elliptic curve, the modular curve), use constructions like the Tate module (of its Jacobian abelian variety).
On the other hand, constructing Galois representations to automorphic objects (e.g. modular forms) is hard. There are essentially only two methods:
Find your automorphic form in the étale cohomology of some algebraic variety, and then use that to construct the Galois representation.
Find congruences between your automorphic object and other automorphic objects that you've already constructed Galois representations to, and piece the data together.
In the specific case of weight $2$ modular forms, we get lucky: there is an associated algebraic object, and it's just an abelian variety. Explicitly, if $f\in S_2(\Gamma_0(N))$ is a newform with eigenvalue field $E$, then there is an abelian variety $A$ (constructed as a quotient of $J_0(N)$) of dimension $[E:\mathbb Q]$ such that $$L(A, s) = \prod_{\mathrm{Hom}(E, \mathbb C)}L(\sigma(f), s).$$ In particular, the Galois representation associated to $A$, i.e. its Tate module, will decompose as a direct sum of the Galois representations attached to $f$ and its Galois conjugates $\sigma(f)$. The role of this abelian variety is absolutely crucial!!
But we got very lucky, in fact double lucky:
This second point is crucial! For example, weight $2$ modular forms over other fields with integer Hecke eigenvalues (e.g. Hilbert modular forms, Bianchi modular forms) should also (normally) correspond to elliptic curves over those fields, but there is no known direct construction in those cases!
For modular forms $f$ of weight $>2$, there is no way to associate an abelian variety to $f$, so we can't use a construction as simple as the Tate module. We can still find $f$ in the cohomology of the modular curve (no longer with constant coefficients), but we're forced to use the more general sledgehammer of étale cohomology.
For modular forms $f$ of weight $1$, the story is even worse. We can't find $f$ in étale cohomology at all. Instead, we have to use method $2$. The trick is to notice that, if $p$ is prime and $E_{p-1}$ is the weight $p-1$ Eisenstein series, then $E_{p-1} \equiv 1 \pmod p$. So $fE_p$ is a cusp form of weight $p$, that is congruent to $f$ modulo $p$. Piecing together Galois representations for different $p$ (and overcoming the major problem that $fE_p$ is not an eigenform!), Deligne–Serre built a Galois representation attached to $f$.