Basically there are two ways to go. Spray foam (two part mixed pour foam) or block pre-made foam. Each has it's advantages and disadvantages.
If this is a one off boat the best and least expensive way to go is block foam in boxes under the seats. You can buy it at any hardware store (blue or pink insulation foam) cut it to size and put it in place.
If this is a production boat pour foam with a gun that mixes it and sprays it in is they way to go. Put compartments on the boat for the foam leaving a hole that can be sealed with a cap, and spray the foam in.
Block foam is usually polystyrene (not styrofoam) and is subject to damage by gas, oiks and various cleaners, so it must be installed out of the bilges, and where it won't be exposed to those. Sealed compartments or bagging will work.
Pour foam (polyurethane) is not subject to degradation by gas, oils and cleaners, but is notorious for absorbing water. So it to has to be sealed or bagged. But it can be in the bilges or other places where water collects.
Of course there are alternatives. Air chambers. but it must be able to float when swamped with the largest airchamber punctured.
Air bags that inflate is an option.
Other things can be used. I have seen plastic bottles, ping pong balls, pool noodles, even beer cans. Use your imagination.