A heatsink is a relatively large mass of good thermally conductive (heat conductive) material, such as aluminium, often coated black. Similar to a sponge soaking up water, it soaks up heat from things that are attached to it. In the photo on the left below you can see black coated aluminium heatsinks bolted onto the side of my 30kV high voltage power supply.
The parts on the left came from the same electronics store where I bought the transistors. Often they give them free with the transistors. The heatsinks on the right I scavenged from various devices over the years. For the power supply I used a hacksaw to cut away heatsink material from the large piece.
On the left in the diagram below you can see where the thermally conductive paste goes. Its purpose is to fill in any gaps between the heatsink, washer and transistor to improve heat conduction. The securing plate goes on the other side of the heatsink.
On the right you can see that the electrically conductive parts extend through holes in all these layers to reach the other side.
As the following photo illustrates, when lining up the transistor with the heatsink and putting the prongs through the appropriate holes in the heatsink, make sure the prongs will not be touching the heatsink itself.
The following is a video I made showing details of mounting a transistor to a heatsink.