If Christ justified that it is okay to do good works on the Sabbath, why did the 2 Marys observe the commandment of the Sabbath and not anoint Christ's body until afterwards?
According to Jesus, there are times when the Sabath restriction comes into conflict with higher commands of Scripture, and in these cases the higher command should be followed and the Sabbath restriction ignored. Jesus gives an example of such a situation in Luke:
Luke 14:3 And Jesus answered and spoke to the lawyers and Pharisees, saying, “Is it lawful to heal on the Sabbath, or not?”
Luke 14:4 But they kept silent. And He took hold of him and healed him, and sent him away.
Luke 14:5 And He said to them, “Which one of you will have a son or an ox fall into a well, and will not immediately pull him out on a Sabbath day?”
As Jesus pointed out, healing a person or saving the life of a person (or animal) was a higher priority than observing a Sabbath restriction, but these exceptions were relatively rare. Generally speaking, only actions taken to preserve life were considered a greater priority than obeying the Sabbath commandment, as Jesus illustrated.
Therefore, the work of preparing an already dead body for burial was not greater than obeying the Sabbath. Since the person was already dead, there was no compelling reason to ignore the Sabbath. This was the case for Jesus' body as well, though it would have been a dishonor to leave Him unburied.