I cook things in a pan on the hob, sometimes for an hour or two, and end up with a thick black layer on the bottom. If I used a cast iron pot, would that still happen?
The situation you describe is burnt material all over the base of the pan. That is caused by using too high heat and would not be helped by using a heavier pan.
The point of a heavier pan is to spread the heat more evenly across the base. A very thin pan would effectively transfer the heat of the burner directly to the food. It would be very hot where the burner was, and noticeably cooler away from it, and food would be likely to burn at the hot spots. With a thicker base, the burner heats parts of the base but the heat spreads throughout it before reaching the food. That means there are no hot spots, so the food won't burn unless the whole pan is hot enough to cause burning, which it sounds like yours was.
One way to think about it is that a thick or thin pan doesn't significantly affect the average temperature but the whole of the thick pan will be at the average temperature, whereas the thin pan will have hot areas and cool areas.
In your case, it sounds like you need a lower heat, more frequent stirring and possibly more liquid, if that would be appropriate to your dish. (Liquid can convect and disperse the heat through the food.)
A heavy based pot will not prevent burning, but it help a great deal as more mass retains and distributes heat evenly, allowing more flexibility with temperature. Depending on what you are cooking, stirring will also help.
There is also the issue of cooking technique. It would be beneficial to know what you are preparing. If, for example, you begin a stew by browning meat and aromatics, the fond that forms at the bottom of the pot needs to be released to help form/flavor the sauce. Normally this is done with the addition of a small amount of liquid and scraping the fond free with a wooden spoon. If you don't do this, you will be both losing a lot of flavor, and creating conditions for the fond to burn at the bottom of your pot later during the rest of the cooking process. A heavy bottom pan has advantages in the creation of this fond.
I would suggest enameled cast iron rather than non-enameled. Maintenance is a bit easier and you can usually avoid a black colored surface, which will help you more easily see browning. Even a stainless pot with a copper layer, or a heavy aluminum pot can work. Mass of the cooking vessel does make a difference in your ability to produce consistent results.
No, a heavy-based pot will not prevent burned food. You should reduce the heat and stir more frequectly; especially stir the bottom of the pot
You can replicate the thermal mass of a very heavy pot by using a heat diffuser plate. They are widely available online and in kitchen stores. The extra thermal mass does a great job of evening the temperature and raises the pan away from the heat source. Some of the burner energy is also radiated out to the room (if the plate is larger than the bottom of the pan) which may help address your inability to fine tune the gas burner.