When should you raise partner’s opening bid of 1♥️ or 1♠️ immediately to game? And when should you take a longer route?

South was dealing, with no one vulnerable, on this board:

                              NORTH
                             ♠️ K 8 7 5
                             ♥️ Q
                             ♦️ A K Q J 4 3
                             ♣️ K 5

WEST                                                EAST
♠️ J 10                                             ♠️ 9 3
♥️ 10 9 8 7                                      ♥️ J 6 5 2
♦️ 9 8 6                                           ♦️ 10 5 2
♣️ A Q 7 3                                      ♣️ J 9 8 6

                            SOUTH
                           ♠️ A Q 6 4 2
                           ♥️ A K 4 3
                           ♦️ 7
                           ♣️ 10 4 2

The bidding proceeded as follows:

South              West          North         East
1♠️                  Pass          4♠️            All Pass

Opening lead: ♥️10

This happens all the time. North saw partner’s 1♠️ bid, thought “An opener opposite and opener equals game,” and raised to 4♠️ with what is intended to be a shutout bid.
Do you see a problem here? Unless West leads the ♣️A, North-South will make 13 tricks.

North should have seen slam potential and bid more deliberately. There are sophisticated ways to get there; but even if you don’t use Jacoby 2NT, splinters or Roman Key Card Blackwood you can bid a slam. Try this auction:

South           West         North           East
1♠️               Pass         2♦️               Pass
2♥️              Pass         3♠️•              Pass
4♠️              Pass         4NT               Pass
5♥️••           Pass         6NT•• •        All Pass

• Forcing

•• Showing two aces

••• Safe bid to put East on the lead and prevent West from leading through North’s ♣️K5

What if you have the same kind of hand you figure your partner has shown? You still don’t want to go directly to game because you’ll be preventing partner from investigating a possible slam. Here’s another version of North:

     NORTH
     ♠️ K 8 7 5
     ♥️ 6
     ♦️ A K 5 4 3
     ♣️ K 5 3

     SOUTH
     ♠️ A Q 6 4 2
     ♥️ A K 4 3
     ♦️ 7
     ♣️ 10 4 2

The auction should proceed as follows:

South            West           North          East
1♠️                Pass           2♦️             Pass
2♥️               Pass           4♠️             All Pass

Are there times to raise 1♥️ or 1♠️ to game immediately? Yes. Let’s change the North hand again:

     NORTH
     ♠️ K 8 7 5 3
     ♥️ Q
     ♦️ 10 8 5 4 2
     ♣️ 7 5

     SOUTH
     ♠️ A Q 6 4 2
     ♥️ A K 10 3
     ♦️ 6
     ♣️ J 4 2

When you have 5+ trump support, 0-9 high-card points and ideally shortness somewhere, raise to game with what is called a “weak-freak” bid. Even if the contract doesn’t make, it can be pre-emptive.