A cyst is a closed sac, having a distinct membrane and division compared with the nearby tissue. Hence, it is a cluster of cells that has grouped together to form a sac (not unlike the manner in which water molecules group together, forming a bubble); however, the distinguishing aspect of a cyst is that the cells forming the “shell” of such a sac are distinctly abnormal (in both appearance and behaviour) when compared with all surrounding cells for that given location. It may contain air, fluids, or semi-solid material. A collection of pus is called an abscess, not a cyst. Once formed, sometimes a cyst may resolve on its own. When a cyst fails to resolve, it may need to be removed surgically, but that would depend upon its type and location.
Cancer-related cysts are formed as a defense mechanism for the body, following the development of mutations that lead to an uncontrolled cellular division. Once that mutation has occurred, the affected cells divide incessantly (and become known as cancerous), forming a tumour. The body encapsulates those cells to try to prevent them from continuing their division and to try to contain the tumour, which becomes known as a cyst. That said, the cancerous cells still may mutate further and gain the ability to form their own blood vessels, from which they receive nourishment before being contained. Once that happens, the capsule becomes useless and the tumour may advance from benign to a cancer.