It’s complicated…
The PM gets various different sorts of question. Firstly there the questions from IDS and Charles Kennedy - IDS automatically gets 6 and Charlie Keendy automatically gets two. The PM has no idea whatsover what these are going to be on.
Next there are the tabled questions. MPs have to put these down in advance, so in theory the PM would already know what they are and would have a prepared answer. This does sometimes happen if an MP wants to raise a question about a constituency matter and get a proper answer. After recieving a reply from the PM, the MP gets a supplemental quesion, which has to be on the same topic.
Of course, if it all worked like this the PM would know all the answers in advance, so about 99% of tabled questions are deliberately meaningless ones designed to allow a supplemental question on any topic the MP may desire. They come in one of two forms either “what are the Prime Minister’s appointments for the day?” or “has the Prime Minister any plans to visit my consistuency?”. To save time, MPs don’t actually ask the question, they just yell out the number on the order paper (“number one, Mr Speaker!”) The PM then gives the standard answer, for the first question - “I have had meetings with ministerial colleagues and orders, and in addition to my duties in the House, I will have further such meetings later today” and for further questions “I refer the honourable gentleman to the answer I gave some moments ago”. THEN the MP asks his real question, which is now a surprise to the PM.
After this there is a third type of question, which is additional supplementals from other MPs. After the PM has given the answer to the supplemental question, other MPs can try to “catch the speaker’s eye” to ask a question on the same topic. Obviously, since the topic is normally the Prime Minister’s appointments for the day, this means it can be on any subject they so desire. When the question was about the PM’s plans to visit a constituency, or a specific closed question, obviously it is less likely that an MP will have a question on the same subject.
So (pause to catch breath) the PM will only officially know the subject of a tiny proportion of questions, however, in practice questions from supporters will be advised in advance, and as Pjen says, often deliberately planted by the PM’s office. For other questions, the PM’s office provide answers for likely questions, based on who has questions on the order paper and what stories are in the news.
For example, say Teddy Taylor has a question on the order paper - the order paper will only have “will the PM gives his appointments for the day” but the PM’s office will know that Teddy Taylor is obsessed with Europe, it’s 95% certain that he will be asking something about Europe, and will give the PM appropriate info in his folder to answer the question. Similarly, they will look at the news that week, see some poor crime figures have come out and guess that IDS will ask about them, and hence give the PM suggested rebuttal points to that in his folder.