It's not necessarily a fallacy, because the argument that Y and Z are equivalent or sufficiently similar to both justify X is a valid argument.
The argument that they're similar might be an example of a false equivalency however, which is an informal fallacy, and so depends on the circumstances of the argument, since it's not de facto invalid to draw an equivalence between two things.
A simple fine is a just punishment for littering. Someone threw a bag of trash out of their car on the highway (illegal dumping, not littering). Because a fine is justified for littering, and illegal dumping is similar to littering, a fine is justified for illegal dumping.
The equivalence between littering and dumping isn't unreasonable.
A simple fine is a just punishment for littering. Someone burnt down an orphanage (arson and heinous murder, not littering). Because a fine is justified for littering, and arson and murder are also crimes, a fine is justified for them as well.
The equivalence between littering and murder is weak at best, and most would find it unconvincing that we should treat them the same.
(There's a fun related problem where the equivalence is bad, but both conclusions are actually agreeable. It can lead to some weird arguments. "Hitler deserved to be removed from power. Hitler was a man. Stalin was also a man, and therefore deserved to be removed from power")