What is the exact statement of "there are 27 lines on a cubic"?
The exact statement is that every smooth cubic surface in $\mathbb P^3$ (over an algebraically closed field) has exactly $27$ lines on it. Many books on algebraic geometry include a proof of this famous fact. The proof that I first learned comes from chapter V of Hartshorne, where cubic surfaces arise as the blowup of $\mathbb P^2$ at $6$ points, and where the formula $27=6+15+6$ is explained.
There is a completely elementary (i.e. no surface theory or Chern classes needed) way to carry out this computation. I give you a brief sketch omitting the details. First use an incidence correspondence to prove that every cubic (smooth or not) contains at least one line.
Once you have a line l consider planes $H$ containing $l$. The intersection of $H$ with the cubic is either ($l$ + a smooth conic) or three lines. Moreover in the second case the three lines are distinct and do not meet in one point, otherwise the cubic would not be smooth there.
The planes containing $l$ form a $\mathbb{P}^1$, and a simple computation tells you when the residual conic in the plane is smooth. Namely the vanishing of the determinant of the residual conic is an equation of degree 5. This equation has distinct roots, again because the cubic is smooth.
We conclude that for a given line $l$ there are exactly $5$ planes through $l$ on which the cubic decomposes as the union of three lines. Said differently, every line meets exactly $10$ other lines.
From the last statement it is a combinatorial exercise to prove that the total number of lines is $27$.
I hope the sketch is clear enough; feel free to ask more details if some step is too obscure.
I recommend Jack Huizenga's answer to the question to "Why are there exactly 27 straight lines on a smooth cubic surface?" on Quora. It's detailed and well-written.