You could have bought from the guard on either of your trains, at the excess fares booth at Reading (near the ticket gates), at the normal ticket office at Guildford, or the ticket machines at Guildford (which are equipped to sell tickets from another station).