Welcome to the forum!
When you Union 2 (or more) objects, they become one object, which can only have one style (color, among other things). If you want them to keep 2 different colors, then don't Union them.
If you need them to be unioned, AND you need them 2 colors, then you'll need to duplicate the original objects, then union the duplicates. Then remove the color from the unioned object. Then you might want to group everything together, so that they stay together.
If it's not quite that simple, feel free to share the SVG file with us, and we could show specifics.