Controlling competing phases of magnetic intermetallics and bioceramics