Word To Describe Changing the Rules of Some Situation For An End Goal

It’s likely that you’re thinking of “moving the goalposts”:

Moving the goalposts (or shifting the goalposts) is a metaphor, derived from goal-based sports, that means to change the criterion (goal) of a process or competition while it is still in progress, in such a way that the new goal offers one side an intentional advantage or disadvantage.

(quoted from Wikipedia, at link)