Non-expanding foam, or low-expansion foam, has a number of applications where it outperforms nearly every other material such as insulating small cracks and holes, waterproofing areas of a house or even insulating very large, hard-to-reach locations.
Low-expansion and non-expansive foams can be made to adhere to surfaces. Since they are insulators they can coat flat surfaces such as crawl spaces, floor joists and surfaces with irregular features like conduit and duct work. Air Krete is one such foam which is made to flow around features and is even heat resistant.
Not all foam seals moisture and air out. Some foams are made to breathe so air can pass through. These foams are used in applications where a moisture barrier would trap water and moisture instead of keeping it out. These foams are also used in applications where it's important to fill a void and a sealant would not be necessary.
There are a number of regular-use or single-use products designed to fill small holes around outlets, windows or doors. These foams come in canisters that dispense a very small, controlled amount of foam. One such product is Great Stuff, which is available at most home stores.