In our system of federalism, states are not required to have the exact same laws as the federal government. There are areas of law in which the states can have different laws. However, there are also areas in which the federal government’s laws supersede state laws and state laws may not legally contradict the federal laws.
The death penalty is an area in which a state law may differ from a federal law without contradicting it. Federal laws allow for the death penalty in a variety of instances. By contrast, there are states that do not allow the death penalty. These laws are different, but they do not contradict. The state may continue to ban the death penalty for cases that are in its jurisdiction without running afoul of federal law.
By contrast, we can look at some recently proposed state laws that would contradict federal law. A number of states are considering laws that would prevent federal officials from enforcing gun laws within those states. Those laws would directly challenge and therefore contradict federal laws. It is very likely that those state laws would be unconstitutional for this reason.