I didn't mean to but I accidentally trespassed.
What were you trying to do when you trespassed?
I was trying to enter a building, and I walked by mistake into the wrong gate.
It's good that you recognize what you did was wrong and it was an accident, but you should be more careful not to trespass in the future. It's inconsiderate and can actually land you in legal trouble if you are caught doing it.
What, but I was walking in the wrong direction.
You just need to pay better attention next time. It's important to know where you are going.