The phrase to move, or to shift, the goalposts means to unfairly alter the conditions or rules of a procedure during its course.
This, of course, is a sports analogy. Actually, I have found two examples in The Forfar Dispatch (Forfar, Angus, Scotland) of the use of the phrase as a pleasantry denoting the only way for an unsuccessful soccer team to score a goal:
1: On Thursday 21st February 1946, this newspaper published the account of a goalless match between Forfar Athletic and Montrose:
Rank bad finishing was mainly responsible for the complete blank, for there is no denying the fact that opportunities galore were there for the taking—most elementary openings but with no takers. Montrose were the chief sinners in this respect. “Shift the goalposts,” said someone as the seasiders repeatedly finished wide of the mark. But that wouldn’t have made much difference so long as Black was left to guard them.
2: On Thursday 11th March 1948, the account of a match between Forfar Athletic and Stirling Albion mentioned:
the bad luck, combined with wretched finishing at times, which attended the Athletic at close quarters;
occasions when the old gag, “shift the goalposts,” could justifiably be applied to the home finishing.
The earliest figurative use of the phrase that I have found is from the various accounts of a debate that took place on Friday 2nd 1924 at the House of Commons, on the Proportional Representation Bill, motioned by Athelstan Rendall (1871-1948), Liberal MP for Thornbury, Gloucestershire.
Context: The general election held on Thursday 6th December 1923 confirmed the decline of the Liberal Party under the first-past-the-post electoral system and produced a hung parliament. Although the Conservatives, led by Stanley Baldwin (1867-1947), won the most seats, the Labour Party under Ramsay MacDonald (1866-1937) formed a minority government—the first ever Labour government—with tacit support from the Liberal Party, relegated to the third place. As a consequence, the Liberals tried to introduce proportional representation as a means of arresting their electoral decline.
The following is from the account of the parliamentary debate published in The Scotsman (Edinburgh, Midlothian, Scotland) of Saturday 3rd May 1924—George Hardie (1873-1937) was Labour MP for Springburn, Glasgow:
Mr Hardie (Soc., Glasgow, Springburn) said if the Liberals had been sincere about this Bill they would have shown when they were in power that they were in favour of it. But his personal view was that a change had taken place, and the Liberals, having been beaten, not only wanted to change the rules of the game, but wanted to shift the goal posts because they could not play any more. That was a rather feeble attitude. It had been said that the Liberals had been holding a pistol at the heads of the Labour party, and that if the latter did not vote for the Bill the Liberals would withdraw their support of the Government. That statement alone would make him vote against the Bill.
Illustration from T’coop Goes North, published in The Bystander (London, England) of Wednesday 27th April 1932: