But how would an agreement have helped in this case? If someone's determined to stay then waving an agreement in their face won't suddenly make them get off your land!
Well, you could 'assist' the squatter by opening your gate, driving his animals along the road to his place, opening his gate and letting them in. If he hasn't got any land then leave them in his garden. Padlock your gate and get your own livestock on the land.
That's extreme, but with an agreement you would at least have the law on your side and the situation would never have progressed so far that he might be able to claim squatters' rights, or that you might contemplate taking that sort of action.
However, any agreement worth its salt will have covered that sort of problem, with stated length of stay, worming policy, fence upkeep, grass care, rent for the period quoted and all the things you possibly wouldn't even have thought of. The body producing the document will have had years of experience in where such things can go wrong.
I think we can't look at 'farmers' through rose tinted specs - farmers cover the same spectrum as everyone else, from honest, caring, considering the best interests of their animals, the land, the environment, their neighbours, the law, and carrying baby lambs around on their shoulders, to uncaring, dishonest, happy to take advantage of anyone giving them an inch and just being generally unpleasant people. Everyone is different. Be prepared.
In fact an agreement is far from being a one sided affair - it's for the renter's safeguarding as well as the landowner, so the renter knows his animals can't be tossed off the land unexpectedly, the rent can't suddenly go up, the land owner can't refuse to maintain the fences and gates - you get the picture.
Having seen humanity in all it's inglorious reality for many decades, I would always play it safe.