At one time, I was bored because of a delayed flight and that question arose in my mind just for curiosity. I haven't observed any mechanism that checks or counts the passengers who get on the aircraft, so there is a possibility of abuse.
I guess airport security is responsible for that. The passenger may try to get on another aircraft or may get in the airport through a different gate. It must be a bigger problem at international airports and terminals.
If the passenger is caught, what does airport security do, just arrest? What does the airline do if they realise the incident before or after the take-off?