The condition occurred after the patient consumed undercooked pork, allowing the taenia solium parasite to form larval cysts in soft tissues.