On most public busses, there is an entrance door and an exit door.
The generally accepted rule is for people entering the bus to enter where you pay and exit toward the rear away from those trying to enter. This helps cut down the time the bus is at the stop and allows it stay on schedule.
Sometimes, the bus will fill up like a sardine can and people exiting may head toward the front where the door is much closer. This is typically an exception and the bus driver will usually let you know when this is acceptable.
There will be times when the rear door opens first for the handicapped (wheelchairs) who need assistance. Wait your turn for the front door to open when others requiring help have been cared for.