Audrey wrote such a great answer! I wanted to add a couple of things as well. It's very hard to understand this when you are just learning cardiology, but generally sounds are produced in the heart (and blood vessels) whenever there is "turbulent" flow in blood that produces sound waves. (Think of it like waves crashing against rocks on the shore.) This can happen via interactions with cardiac/blood vessel walls, and also by valve closures that cause blood flow changes. The key heart sounds in physiology (S1+S2) are produced when valves close due to a pressure difference between chambers of the heart. For example, once the blood has been pushed into the left ventricle (LV) through the mitral (bicuspid) valve, the pressure in that chamber becomes higher than the pressure in the left atrium (LA). That causes the blood to kind of sit back on the valve (that's how I picture it in my head at least - kind of like when you're at the top of a rollercoaster ride about to go backwards). As my cardiology professor says, "blood is dumb - it flows down the path of least resistance." So, technically if there were no valve, the blood from the LV would flow into the LA when the LV pressure becomes higher than the pressure in the LA. However, we have the mitral valve to prevent that from happening and keep blood moving forward! So, when the blood sits back on the mitral valve due to the pressure difference, that's what produces the S1 sound. The same physiologic principles apply to the S2 sound - when the LV contracts, it pushes blood into the aorta through the aortic valve. When the pressure in the aorta exceeds the pressure in the LV, the blood sits back on the aortic valve to close it, producing the S2 sound.
Turbulent flow can also happen in cases when there is high volume, aka more blood is thrown at the walls of the heart, producing an S3 (as Audrey explained above). S3 can happen in conditions like pregnancy (increased circulating volume) and dilated cardiomyopathy (more blood in the LV than there should be). Turbulent flow can also happen when the LV is stiff (e.g., aortic stenosis, LV hypertrophy) and a sound is produced when the LA shoots blood into a stiff LV (e.g., waves crashing against rocks vs sand). I wish I could attach a graphic here because it makes it easier to see - put "cardiac cycle" into Google Images to see a graphic. Hope that is helpful!