The solution is to understand that weak squares and/or unprotected pieces & pawns near the King are the objects of exploitation and attack. That is, the attacker must exploit the weaknesses of the King's position.
For the defender, the first skill to develop is an understanding of how to go about attacking the King's position. The second skill, therefore, is to use the knowledge gained from the first skill to identify and defend/protect weaknesses in the King's position.
To develop these skills, begin with this book...
Bobby Fischer Teaches Chess...a book review...
https://www.chess.com/blog/RussBell/bobby-fischer-teaches-chessa-book-review
then follow up with...
Fundamental Checkmates by Antonio Gude
https://www.amazon.com/Fundamental-Checkmates-Antonio-Gude/dp/1910093807/ref=sr_1_1?crid=254S2B1NA4A0Q&keywords=fundamental+checkmates+gude&qid=1666969491&s=books&sprefix=fundamental+checkmates+gude%2Cstripbooks%2C126&sr=1-1
I may not be using the right terminology, but I consistently crack under an all-out assault on my castled king, generally involving the opposing players pawns and rooks. A game I just lost is a good indicator of this - I ( much to my surprise) played pretty well through most of the game under pressure, but once the real attack on my castled king started it was all mistakes and blunders.
Can anyone recommend specific training for these kinds of scenarios? I know there is a defense tag for puzzles, but 1) most of these aren't around castled king defense and 2) the fact that I'm selecting for defense puzzles makes it much more obvious what kinds of moves I should be making. Any topics,, sites, etc. would be appreciated.