When I saw the position, my first impression was, g pawn is so sad cause if opponent double his rook on g file, it will be harder to safe it. So I immediately thought I have save it.
h file is also open from black's view but not in the chess board. Your king is safe on h and g file.
I am going to show two move I immediately thought of, 24..... f6 and 24.... Kh7.
Let's start with a variation for the second move.
24.... Kh7 25. h6 Hoping for gxh6 that way g and h file will be open from white's perspective. (more info will be added at last). But g6 saves the game and you got your advantage g pawn "well" protected and h file is also protected by opponents pawn if it was open, you will be trouble. Stockfish doesn't like the 24.... Kh7 also doesn't hate it. So it's playable.
Why does Stockfish loves f6 instead of Kh7?
It's simple. When you play f6, there will be tempo on opponents rook so you get "an extra move" and also opens up the possibility to save g pawn by Rf7 and Re7. If there was instantly an attack on the g pawn then I will consider going with Rf7 cause it tells bishop to go to f8 to save g pawn and Rook is superior so it will do it's job. Whereas Re7 will block the diagonal of the bishop.
So just think that, you gotta play a move which will tell another piece what to do. That's the simple strategic plan. Also it is said that you don't have calculate 20 lines. Make short plan, cause in middle you don't know what your opponent is gonna do unless your opponent is Stockfish.
If I were said to play the position, I will consider playing both of the moves I mentioned above, also everytime I will look for better ones if there is. Where Stockfish will play f6 forever.
Let's go to :
Why are you safe in the position?
You castled kingside, so the safest file for your king is h and g. You are safe unless the files are from white's perspective.
What do I mean by open file from white's perspective?
Take your position as example. g file is open from white's perspective cause there's no white's pawn to stop white's attack. Whereas if white had doubled his rook on h file then it would be useless cause there's no attack white got no way to open up the h file unless you are willing to do so. So white will try to take full control of the g file cause there's "no way black can stop the attack" unless you are wise enough.
As I said earlier, you gotta use superior piece for attacking and minor piece for defending (if necessary) so use your bishop for defending g pawn and use rook to attack.
Let's look at Stockfish's move for the position you gave.
24... f4 (talked about it). 24 .... Kh7 (also talked about it) (it's recommended by Stockfish as 3rd move at 20th depth).
24... Re7 followed by f6 if white doubles rook on g file, I don't know why stockfish loves it more than Kh7. cause it takes diagonal of the dark squared bishop.
24... Re6 at first sight I thought it's shitty moves cause it gives away the g pawn. Let's look at the variation 25. Rg1 Kh8. 26. Rxg7 Ng6! (great move giving away the knight and taking a rook). Let's look at another variation: 25. Rg1 g6 26. hxg6 fxg6. I don't like the variation cause all kingside files are open. But Stockfish likes it cause there's no threat g pawn is well protected by the rook and knight. King is also coming to protect. But as a human I may make mistake later in the game for that reason, I don't like it. Also, first variation tricks the opponent.
When you play a game, ask yourself, the files are open but is there attack? Can he attack? If so, can I defend? If there's a way to defend, you are safe. If there's no attack, start your attack so opponent can't start his. He will spend rest of the game defending. But don't overrush.
General Philosophy behind h4 and a4 :
If someone starts with h4 it means, he is likely start his attack on the kingside. and for a4 queenside attack. You don't have to worry about it in the beginning. But in middle-game. In some particular positions instead of castling I will put my king on the f7 and pawn on f6 and e6 if possible. In response to a4 and h4, you can play d4 and e4 whatever you are more familiar with. But b4 has theory. You can learn b4's theory if you like to surprise people. If you like to counterattack then start your attack queenside after developing all your pieces including queen but not rook. If you had put Qc7 then you could confuse your opponent by which way you will castle so his attack might become useless as kingside is already weak for white. You could bring your pieces there faster and start attack there if he had castled kingside and if he castled queenside your pawns will say "Hi" to the opponent's king.
Let your pieces speak for themselves.