XCOM 2 developer Firaxis Games has announced that the multiplayer modes are going to be shut down, if you're using the Windows version that is.
In the support article, it notes "As a heads up to the XCOM 2 community, we wanted to share that we will be retiring services for Multiplayer and Challenge Mode for the Steam version of the game". Why? Resources (money): "The decision to retire these services isn’t something done lightly, but it does allow us to refocus our resources". Planned for March 28, it's a shame but there's an interesting silver lining here. If you run Linux, or the Steam Deck, you will still be able to play it online as it also mentions how "this won’t affect XCOM 2 on console platforms, or on Mac and Linux".
That's definitely a strange turn of events, with the Linux and macOS versions being done externally by Feral Interactive.
However, things can change and it's entirely possible Feral could eventually update the port in some way to also remove multiplayer at any point. For Steam Deck, the "Playable" verification was done using the Steam Play Proton compatibility layer, so you would need to switch it to the Native Linux build for online modes to work after March 28 (video guide).
That same issue can happen to any game across any platform, nothing is forever — unless developers and publishers offer up server files to players like the good old days.