Think nonsexual thoughts -- about homework or an upcoming sports event.
If you wear boxer shorts and often get erections, consider wearing briefs or boxer-brief underwear.
Just stay seated and try to chill until the erection goes away. If you have to get off the bus, consider untucking your shirt. Or use your backpack or a textbook to shield it.