I have a cyst. Did I get it because I've been taking a bad care of my skin?

Not usually. A cyst can develop from a blocked pore or ingrown hair and represents a lesion often seen in acne. Cysts can often resolve spontaneously but in some cases can be treated by incision and drainage , surgical removal , steroid injections and/or antibiotics.
No. Most cysts come from invagination of the skin surrounding a follicle. Some theorize that follicular injury is what causes cysts to form. Some people are simply more prone to developing cysts, just by the nature of their skin (analogous to acne prone skin). It's not a sign of dirty skin or poor skin care.