They are related. You take a loan from a bank. They extend you credit.
It's rather complicated though. You can have a line of credit, which works like a loan, in which you can borrow up to a certain amount, pay it back, borrow more, pay that back, etc. That can be useful if you have a series of expenses coming up and your income will not be coming at the same time as the expenses. Or you can simply take out a loan, in which you get all the money up front and make regular payments of a set amount at set intervals until it's paid off.
If you "have a hard time getting credit" it means banks don't want to lend you money.