I seem to remember when elections had to take place every four years.
fairly sure that in recent memory, the maximum has been 5 years, but many governments have opted to go for an election for 4 years. there's been a tendency on the part of the opposition party and their friends in the media to accuse a government that stays longer than 4 years being 'clinging to office' / 'afraid of going to the country' and in many cases a government that's hung on for 5 years has gone on to lose, or have won unexpectedly and / or with quite a small majority. There is also a risk to incumbent government that something unexpected might hit the fan in the 5th year so going after 4 years at least gives them some control over the timing rather than having to go at the last minute.
the com-dem government brought in a bullshit fixed term parliaments act which meant instead of it being solely decision of the incumbent government, it would require a commons vote to hold an election early.
for example, after 1945, from perspective of the governing party before the election
1950 (5 years) - labour won but by very small majority
1951 (1 year) - labour lost
1955, 1959 (4 year) - tories won
1964 (5 year) - tories lost
1966 (2 year) - labour won
1970 (4 year) - labour lost
1974 (4 year) - tories lost
1979 (5 year) - labour lost
1983, 1987 (4 year) - tories won
1992 (5 year) - tories won
1997 (5 year) - tories lost
2001, 2005 (4 year) - labour won
2010 (5 year) - labour lost
2015 (5 year) - tories won
2017 and 2019 (2 years) - tories won
2024 (not quite 5 years) - in play.
From what I gather, the tory losses in 1964 and 1992 and labour loss in 1979 - each after 5 years - were not at all unexpected.
The tory wins in 1992 and 2015 - again each after 5 years - were against the expectations of at least some of the polls and commentators.