How flexible is grant funding? I have two questions about grants:

If someone wins a grant, do they have to perform research exactly
about the questions they proposed in the grant? Or, is there room to
change the research question later?

What to do if there is uncertainty when I do not know which lab
or even country I will be in the coming year. As I understand, the
grant is written with the help of a PI and ideally the research is
done in their lab. Do people set in the stone where they want to do
the research before writing the grant? If the postdoc has to move to
another country, what happens to the grant? Is it divided between
the postdoc and the PI?
I'm going to assume the US and the National Science Foundation for the purposes of this answer because it's the main thing I have experience with. Also, &quot;IT DEPENDS&quot;:

If the research question needs to change a bit because the research isn't going exactly where you thought it would, the Principal Investigator should have a discussion with the Program Officer/Manager assigned to them by NSF. There's some slop in the system. They'll probably want you to follow the science. Biology awards probably can't be turned into pure theoretical Mathematics ones, but the PO will be able to guide the PI.
NSF money can't be used to pay a foreign national to work in their home country (nor an American in a foreign one) except under extreme circumstances or ones required by the science (think Large Hadron Collider or the Antarctic Program). The grant is to the institution under the direction of the PI, not directly to the PI and other named people. And, if the postdoc decides to go back to their home country, they just go home and don't get to work on the project anymore unless another source of funding with different rules comes along. If the PI decides to move from Harvard to Yale and wants to take the grant with them, then they can ask Harvard to release it to Yale and NSF for their permission, and maybe it'll all work out. Happens all the time. There were certain advantages at review-time for awarding the grant to the PI when they were at Harvard (Facilities document), now NSF has to decide if Yale is a good enough substitute. I've never heard of it not working out, but it might if the PI was taking a big step down (Harvard to a community college, maybe?). If the PI were trying to take an Engineering Research Center (ERC) or telescope or supercomputer with them, then everyone would probably say &quot;no.&quot;