As he had re-entered the UK from Ireland within the previous 3 months he was legally in the UK despite his passport being forged.
From Wiki:
Immigration records show that Menezes entered the Republic of Ireland from France on 23 April 2005. There are no records to show the exact date that he returned to the UK; however, under the Common Travel Area system, a foreign citizen entering the UK through the Republic of Ireland has an automatic right to remain for three months. Therefore, Menezes was lawfully in the UK on the day he was killed, even though the stamp in his passport recording indefinite leave to remain was a forgery
From the BBC News:
The court heard how as a person entering Britain from Ireland, he would have had an automatic three-month leave to remain which at the earliest would have run out on 23 July, the day after he was killed.