1 Be in an offside position when a ball is played by a teammate. Obviously that happened here.
2. Get involved in active play. Typically that means playing the ball. But it doesn't have to. Interfering with the GK would count. But simply being in the vicinity isn't enough. And you can't speculate what the other player was thinking. The fact that the Sweden player was in front of Loyd and not being screened or interfered with was what probably made the difference here. Loyd wasn't activity involved in play despite being in the vicinity.