Sometimes it's a good move. Here are two common openings
In other cases it's usually not a terrible move, but it's usually not played because there are usually better moves.
In particular in the opening it's more important to bring your knights and bishops off the back rank and castle.
Also it's probably worth mentioning that if moves like h3 forced the bishop to capture your knight, then it would often be a good move... but often the bishop can retreat and keep pinning the knight. To break the pin with two pawn moves is doubled edged because it damages your pawn structure or just moves the pawns closer to the opponent... and pawns need pieces to support them, so again, in the opening it's usually better to first bring out your pieces, and then move the pawns later.
Why is A6 or H3 (pawn forward one) not a good immediate defence against Bishop B5 / G4?
In all strategy recommendations, it's always not the first response for pawn to put pressure on. Why is this?