I may be off base here, but it sounds to me like you just aren't interested in the subjects. One of the biggest factors to learning is how much interest you have. There are tricks you can do to get yourself more interested, but it does take a fair amount of work and isn't always effective. But if you wonder why sometimes we can remember silly details or whole complicated plotlines from stories but can't remember a si…
Programming is a very demanding trade, and I don't think you can do it just for the paycheck, you need to have some degree of passion for it. If someone disagrees with me about this I'd love to hear different takes.