Foam made specifically for blocking or absorbing sound in a room is called acoustic foam. It comes in different shapes, sizes ...
Soundproofing keeps noise from coming in ... such as searching for gaps and filling them with caulk, or packing acoustic foam around the window frame. Small gaps can allow in a lot of noise.