In order for the word "credit" to make sense in all these contexts, it's necessary to study accounting. There is logic to it, even though it doesn't seem that way. :D
1. If your bank balance is negative then you're in debit (or in debt to the bank). Your account is in debit relative to the number zero. If you pay in a check that more than covers your debt, then your bank balance is in credit (relative to the number 0), in other words your balance is a positive number. People say "I'm in" when they mean "My account is in" in these situations. "I'm in credit" actually means "<some particular account of mine> is in credit". Whether a person is in net debit or credit is a function of the sum of all their assets and liabilities. If someone has an unpaid mortgage then it's quite likely they're in overall debt.
2. This one's a bit more complicated because "credit" is also used specifically for study scores. But, in general, being "credited with <something>" means to "pay into an account" (either a figurative or literal account and payment). This time the credit is not relative to zero, but relative to what was there before (because it's a transaction and not a balance). Here, the student basically had 2 years of study credits "paid" into their figurative (or perhaps literal) account of study credits. But you can "credit" someone with anything of value by giving them the thing.