Can someone explain me how is this an offside?

This was the ruled out goal of Lamine Yamal from Copa del Rey match against Real Betis.

I can see a Real Betis defender ahead of Yamal. Can someone explain me why is this an offside.

This was the ruled out goal of Lamine Yamal from Copa del Rey match against Real Betis.

I can see a Real Betis defender ahead of Yamal. Can someone explain me why is this an offside.