Look at a book like Dvoretsky's School of Chess Excellence 2: Tactical Play (or something with the same idea but less advanced), find your candidate moves, analyze them, thoroughly look at checks, captures, and threats, ask yourself what will you get out of an attacking move (positional judgment and evaluation comes into play here).
If your king attack just helps him enter a superior endgame then you have to ditch it, but if he is forced to make major concessions then go for it.
An attack requires calculation and positional skills since you want to aggressively force a superior position if you can. If you overlook a refutation to your move then that's something you need to work on.
How to find the best defense against unsound attacks or choose the best attacking move from a number of viable options.What practice to inculcate to be strong on these fronts.Please help me out stronger players.