Cooking will kill only active bacteria, but not the heat-resistant spores, nor the heat-stable toxins already created by bacteria, which means cooking your food doesn't make it automatically safe. The dormant bacteria will not be killed by cooking, and will be activated as your cooked food falls back into the danger zone.
Some bacteria such as Listeria monocytogenes (found in vegetables when manure was used as fertilizer, and in dairy products) can grow while in the fridge, and even survive minimum pasteurization times!