In d4-d5 openings, when one side plays f3 or f6 in order to build a big center, it's often a good idea for the other side to play c5 or c4 immediately to strike their center before it overwhelms you. If dxc is played, then after Bxc it comes with check (or prevents your opponent from castling in the first place). Your opponent is no longer able to get two pawns uncontested in the center. If dxc is not played, then the d pawn probably requires more protection. Once again they are dissuaded from getting in their desired e4 or e5 move and taking over the center.
This situation often comes from a Queens Gambit Declined Exchange variation, where white plays Nge2 and f3-e4, the so-called Botvinnik or Kasparov plan. Black is usually quick to play c5 to challenge this plan directly.
[FEN ""]
1. d4 Nf6 2. c4 e6 3. Nc3 d5 4. cxd5 exd5 5. Bg5 Be7 6. e3 c6 7. Bd3 Nbd7 8. Qc2 O-O 9. Nge2 Re8 10. O-O Nf8 11. f3
Now let's compare your two positions. In the first case, white has already played c3, so playing c4 so soon afterwards would be a waste of time. Moreover, white does not have a lead in development and their king is quite far away from castling, so wasting time on pawn moves will not give them an advantage.
In the second case, white has a lead in development and is a lot closer to kingside castling than black. That means that they want to blow open the center and try and prove these two dynamic issues matter more than any static advantage black might create by getting two pawns in the center. For all of the above reasons, this is exactly the type of situation where c4 is 100% called for.