Here's the deal. I was recently watching a replay of the Copa do Brasil match involving Flamengo vs. Cruzeiro. It was the 85th minute(?) and Flamengo were a goal down at that point. The ball was played from outside the box as the Cruzeiro defenders bunched up to prevent any runs into the box. A forward cross was launched over the defenders. The goalie ran up to grab the ball but he misjudged the timing. One Flamengo player was in the box ready to pounce on the ball. A Cruzeiro player was standing right in front of the goal line to cover the goal, making the Flamengo player still "ahead" of the defense. But there's a rule that says that there has to be at least two defenders in the same line or the offsides is called. I never heard of that rule. Is that rule applicable for all sanctioned matches or just for the Brasilian matches? I never seen that rule applied elsewhere. How would the "two-defender" rule come into play?
Offside is indeed called when there are less than two defenders at least in line with the attacker when the ball is played. The rule is applicable in all sanctioned matches. I think your confusion is because generally, the goalkeeper would be in his goal, counting as one defender, therefore leaving the forward to worry about only one outfield defender. It sounds like the attacker was behind the keeper, so he then needs two outfield players to be at least in-line with him to be onside.
That rule would be the offside rule. The goalkeeper is a defender and there must always be two defenders to keep someone onside.
As an instructor, I've always found it less confusing to refer to them simply as opponents rather than defenders. Some take the term "defenders" literally, if you can believe it and think it excludes other positions on the field.
IIRC, this happened in one of the Champions Leagues matches that was broadcasted in the last few months. The ref made the correct offside call and Tommy Smyth made a good explanation immediately. It might have been more fun listening to Ty's explanation of what really happened.