Firstly, in order to prevent cockroaches, you have to keep your kitchen clean - don't leave crumbs or food out in the open. Cockroaches love flour, so take it out of the bag and seal it in a plastic container. They also love bread crumbs and other wheat-based goods, so store them in plastic - you can put the cardboard boxes in Ziploc bags, for example.
If you already have cockroaches, there are several things you can do. Observe the cockroaches and try to figure out where they are coming from, and seal the openings with clear caulk when you find them. Cockroaches are flat and can get through small openings, so keep an eye out.
Cockroaches love cocoa powder and flour, so mix equal parts of cocoa powder or flour with diatomaceous earth (found in hardware stores and online) and sprinkle it near cockroach entryways or in places where you've seen the cockroaches. Note that cocoa powder can stain light-colored carpets. Diatomaceous earth is non-toxic to pets and humans, but it kills insects by destroying their exoskeletons. The roaches will take the "bait" back to their nest and feed it to the other roaches, who will also die. You can use borax powder (found in the laundry soap aisle of most supermarkets) in place of diatomaceous earth if you like.