Edit to add - as per your experience the team themselves were pretty good to work with but in my case they had no sway (or at least said they didn't) with whatever archaic nested babushka-esque financial and legal mechanisms this century-old institute had. Perhaps if I'd put my foot down and refused to work it would have forced a proper renegotiation and worked out better in the end but it was a constant state of "we'll be finished next week, just one more thing" so the old sunk cost fallacy was always in deadlock with pragmatism and the frog slowly boiled.
As a contractor/freelancer you can do any kind of contracts. You can commit to free work for whole year if you want (or are stupid enough to sign a contract that requires you to work for free).
With normal employment there are lots of laws that protect you so you don't have to think about your contractual duties. Just turn up and do what is told and you will get paid. When you do contracting it is quite different game.
Don't, under any circumstances, do that.
If the client asks for a fixed price, then don't propose an implementation cost. Instead, propose a discovery cost. I can easily say how long I'll need to figure out what needs to be done and deliver a documented solution with an estimate of the work needed.
If they refuse this approach, then the only other option is "time and materials", i.e. I will send you a log each week of the hours I've worked and the product I've delivered, and you will pay me each week.
If they refuse discovery as well as time and materials, and insist on fixed price, then I walk away.