11th hour post before the release of Season 8 but I just wanted to get this out there
After watching Season 7, I thought about how James possibly wanted to apologise to Keith about the incredibly rude remark he made about his parents back when they were kids
(THIS IS JUST MY INTERPRETATION OF THE SCENES FROM SEASON 7 AND ARE BY NO MEANS CANON)
James probably told himself he would apologise to Keith the next time he sees him but when he does, he couldn't bring himself to because he was so mad and ashamed at himself that he could have unintentionally ended up projecting it as a sort of coldness towards Keith before walking away
And it's possibly difficult for James to actually say "I'm sorry" and admit he's wrong considering the amount of pride he has (remember how he insisted he could find his way around without Veronica's help even though he knew he couldn't)
When James yelled at Keith and Hunk during that meeting when they kept insisting on saving Hunk's family, it likely wasn't because he was trying to assert his authority or anything but rather to cut off the discussion as soon as possible so the Garrison wouldn't decide to increase security around the vehicles to prevent them from 'borrowing' one to save Hunk's family (and knowing Keith's history with authority, and also stealing Shiro's vehicle that one time, it was even more crucial to end the discussion right there and then)
From the VLD bios, it's stated that James is a "stickler to the rules" and yet he willingly goes behind the Garrison's back to help Hunk and Keith save Hunk's family
James probably knew that that couldn't be counted as an apology, but until he manages to push his pride aside (and also because of how he's probably not good at emotional situations), he likely wanted to show Keith that he has matured and that he understood how important family was and the lengths one would go to protect it. He knew he couldn't take back the stupid words he said to Keith all those years back so the least he could do then was to put on the line what he had (his leadership position, the good cadet image he built up, etc) to help them save Hunk's family
Again, he's probably not that good at really emotional things so it's probably a habit or instinct of his to say something cocky or whatnot to distract others from his kinder intentions (like when he mentioned how Keith and Hunk wouldn't survive out there without the fancy blaster thing and how "he doesn't want to see his only hope for saving Earth get hurt")
TLDR: James is trying and isn't a jerk
Again, this is just my interpretation of the scenes from season 7 and I might not be right but I also don't want to dismiss such a possibility either
ALSO FORGIVE ME IF THIS IS KIND OF MESSY because I lowkey rushed through this to get it out before 14 Dec (though I probably shouldn't have left this to the last minute gg)