I tried to replicate the problem, but I don’t get the output you’re getting weirdly enough.
Could you provide a .rvt file where it happens to rule out (or confirm) if its an environment issue?
I can’t say I’ve seen or heard of this before, and also can’t reproduce. Best guess is that it’s either a worksharing issue (your project is workshared, right?) or a system setting (localization perhaps). Checking the coded values via Python as @Nick_Boyts recommended is a great first step.
If it’s not a bug it’s making me think that something else is controlling the phase for those elements, eg. curtain wall, group, something else, and that’s causing the value to be a string instead of the actual element. Can you use Revit Lookup to snoop the parameter value or recreate with python?
Audit the template, then save a copy and see if anything odd happens with file size/element IDs. Also things which are deeply nested (ie: phases) get weird with non-workshared files, so double check that the .rvts you are working with have worksharing set up and nothing marked as ‘owned’.