The biggest factor by far is payment history, roughly 35% of a typical credit score. Late payments, collections, and bankruptcies hurt the most, and they hurt more the more recent they are.
The next biggest factor is credit utilization, about 30%, which is how much of your available revolving credit you're using. Maxing out cards hurts your score even if you pay on time, so keeping utilization low (often cited as under 30%, ideally lower) helps.
Length of credit history matters too, around 15%. This is part of why it's often a bad idea to close your oldest credit card, since it shortens your average account age. The rest is split between credit mix (having a mix of credit cards, loans, etc.) and new credit inquiries (opening several new accounts in a short window can ding your score temporarily).
A few practical takeaways: pay on time every single month, keep balances well below your limits, don't close old accounts just because you stop using them, and only apply for new credit when you actually need it. Checking your own score (a soft inquiry) doesn't hurt it, only hard inquiries from lenders do.