Your cat and parasites
A number of different parasites can cause weight loss in your cat. Two types, giardia and coccidia, both cause severe diarrhea, which can lead to dehydration and weight loss. A specific version of the second parasite, called toxoplasma gondii, can be passed onto humans, and is ingested when your cat swallows any of the parasite's cysts which lay on the ground. It's essential you see a vet if you believe your cat has an infestation, as they'll be able to specify what parasite it is and how to protect your cat (and you) against it.
Hairballs and cats
Cats spend a significant amount of time grooming themselves, which regulates their body temperature, keeps their hair and skin clean, and also helps manage stress. However, if their hair isn't properly excreted through their digestive system, it can get caught up and form hairballs. These lumps of matted hair can lead to regurgitation, constipation, esophagus blockages, a loss of appetite, and eventual loss of weight.
Vitamin deficiencies in cats
Weight loss, alongside dermatological problems like flaking skin, alopecia, and scratching, can be an indicator of a B vitamin complex deficiency. This vitamin is water-soluble and cannot be stored in the body, therefore your cat's diet must include the vitamin B complex to help maintain a healthy coat and skin.
If you have any concerns about your cat's recent weight loss, make sure to visit your vet; they'll conduct a full examination and be able to address your concerns directly.