How do boats work?

Very carefully. Buoyancy, engine mechanics, fluid dynamics/mechanics, and a whole lot more.