You can leave whenever you wish, there's no obligation to serve any set amount of time.
As for the commitment and the annual camps, they tend to be almost immediately after the end of the university year. On my sqn it used to be the trend that the various universities finished by the first week of june, at which point the camps were held. There is also the option of an SVA [Summer Vacational Attachment] which would last a week, but the timings of these are less fixed, they are also not as compulsory.
If you had a specific reason for requiring a spot on an earlier camp so that you could pursue other interests, there would be nothing wrong with explaining that to the staff and seeing if they can accommodate your needs. Odds are, they will be able to.
It's worth remembering that the UAS isn't there to recruit you. It's there to give you an insight. If you end up joining afterwards, great, if not, the aim is to make you someone who looks back on the UAS and RAF with fondness, to appreciate what it does.