Judges can use a variety of sources to assist them in deciding the purpose of an Act.
The Act itself (in the preamble section at the start) often gives a clue, e.g. The Dangerous Dogs Act 1991 states that it's: "An Act to prohibit persons from having in their possession or custody dogs belonging to types bred for fighting; to impose restrictions in respect of such dogs pending the coming into force of the prohibition; to enable restrictions to be imposed in relation to other types of dog which present a serious danger to the public; to make further provision for securing that dogs are kept under proper control; and for connected purposes".
In addition to that, an individual word is given it's ordinary meaning defined in the Oxford or Collins dictionaries. And, as another contributer mentioned, you may have case law that has already defined the meaning or purpose of an Act or words within an Act, e.g. the meaning of 'making' indecent images of children (within S.52 of the Civic Government (Scotland) Act 1982, is discussed in Longmuir v. HMA, 2000 SCCR 447.
Finally (though there may be more sources), Judges will often consult 'Hansard' (Parliamentary debates), from where bills/Acts were introduced, debated, amended, then passed, prior to it becoming law. These discussions can provide a good insight into the thinking of parliament at the time and why the law was introduced. Read the decision in Pepper v. Hart - a leading case on statutory interpretation and the methods used. ([1993] 1 ALL ER 42).