There are some specialty areas of Chemistry. You can learn about Electrochemistry, Nuclear Chemistry, and Organic Chemistry.
Some reactions give off a lot of heat while other use up a lot of heat.
There are chemicals in those bags that go through a reaction and make heat and cold. Chemists sat in labs with a bunch of chemicals and figured out the best ones to use for those packs. The idea behind those reactions is that chemical bonds store a lot of energy. If you break those bonds, heat is given off. Sometimes when you make bonds, you need a lot of heat, that's when everything around the molecules gets really cold, the heat is sucked out of the area.