The short answer is that, in theory, you only need to watch six movies to learn about Loki, his backstory, and the setting of the Loki TV series. These are:
Thor
Thor 2: The Dark World
Thor 3: Ragnarok
The Avengers (known as Avengers Assemble in the UK)
Avengers: Infinity War
Avengers: Endgame
However, Marvel tie-ins tend to be filled with references to other Marvel properties, which means that without a fuller understanding of the franchise, there will almost certainly be information that slips past you. In other words, the more Marvel movies you watch in preparation for Loki, the better.