If a swimmer swims the breast leg in the prelims, are they allowed to switch to the back for the final?
No. The rules require a relay team to consist of 4 swimmers who each swim one fourth of the race.
I know this from my competitive swimming days. We had one great swimmer and the same thought.
Here is the FINA rule:
SW 10.10 There shall be four swimmers on each relay team.
And now I see that I misread your question. Yes. You can shuffle your team around however you like.
SW 10.13 The members of a relay team and their order of competing must be nominated before the race. Any relay team member may compete in a race only once. The composition of a relay team may be changed between the heats and finals of an event, provided that it is made up from the list of swimmers properly entered by a Member for that event. Failure to swim in the order listed will result in disqualification. Substitutions may be made only in the case of a documented medical emergency.