Had something slightly similar the other evening.
I was on the line, anticipating yellows breaking swiftly from defence, all evening their striker was sitting on or about the last line of defenders.
lol and behold, yellow centre back hoofs it long from the edge of the penalty area. Yellow no. 9 is offside, chases ball down, my flag goes up, ref blows.
Cue a little confusion (for me, the defenders, striker & 20 or so spectators behind me)
Unbeknownst to me (I was concentrating on the off side line, it was dark, the lights were rubbish etc, etc.) there was a late challenge on yellow centre back as/after he hoofed the ball up field, but ref was playing advantage. However, on my flag for offside, no advantage accrued, so ref took game back for free kick to yellow on edge of their area, rather than IDFK to reds for the offside.
We chatted about it in the changing room after the game - right outcome, just at the time was a little confusing for me until Imfigured out that there must have been a foul on yellow before the offside.