There IS an obligation to not retain unlawful possession of xomeone else's property.
Imagine this ...
We are at the checkout in a clothes shop.
You put your purse down next to my bag.
I accidentally pick up your purse and put it in my bag.
You point out that I have your purse.
Could I argue that you put your purse down near me, and there is no legal obligation on me to go into my bag and return it to you?
Obviously not.
Same with the ball.
Theft Act s.3(1) defines theft as ... Any assumption by a person of the rights of an owner, and this includes, where he has ... come by the property (innocently or not) without stealing it, any later assumption of a right to it by keeping or dealing with it as owner.
So ...
"coming by property innocently" (someone kicks their ball into your garden)
and
"keeping it" (by refusing to return it)
... is a theft.
There is no law against going into someone's garden uninvited (otherwise it would be a bit tricky when you got a new postman!).
If someone specifically forbids you from entering their garden, then to do so against those specific instructions is a civil trespass, but their instructions would simply aggravate the theft of your ball.