Fossils are the preserved remains of once-living things. The usual image that springs to mind is of a shell or bone that has been turned to stone, but there are a number of ways this can happen, and a few more methods of fossilisation that don't involve mineralisation.
When something is buried in sand or mud at the bottom of a body of water, it is gradually covered by more and more layers. The pressure and temperature it is subjected to will increase and a slow process of chemical alteration takes place. What the previously living material is turned into depends on the chemical make up of the sediment it is lying in. Fossils formed in this way can be silicifed (replaced by quartz), calcified (calcite), phosphatised or pyritised.
Other ways include burial in tar, peat bog or permafrost, mummifcation in very cold or dry environments, or being trapped in sticky tree sap which may eventually become amber or copal.
There are also trace fossils - not remains of the actual living plant or animal, but signs of their presence. These include footprints, burrows, fossil dung, gizzard stones.
It's hard to become a fossil. The odds are very much against you, but there are a few things that can help.
Get yourself buried as soon as possible - in the mud, in a tarpit, in some permafrost - wherever, but do it quickly... The longer you are exposed to the elements, the more you will decay and the more likely you are to get eaten by something hungry.
Have some hard parts - a shell, some teeth or bones. Soft, fleshy bits are only preserved in exceptional cases. They rot away far quicker and get eaten.
Find the right mud - a finer grain size will often lead to far better detail. The right minerals surrounding you will give you a far better chance. Also - a toxic or anoxic layer just above the sediment surface will help keep you safe from burrowers disrupting things.
Don't let your host rock get destroyed - shifts in the crust and metamorphosis through high temperatures and pressures can deform or destroy any fossil content.