curious Was the attempt to assassinate Hitler a crime?
An example completely incompatible with the issue.
On the other hand, I fully agree with your position that the motive of the perpetrator is relevant to the evaluation of his action. In practice, it will be most important not so much in determining whether a crime has been committed, but in determining the punishment. Let me cite Article 53 paragraph 2 of the Polish Criminal Code, which defines the directives for the assessment of punishment:
In assessing the punishment, the court shall take into account, in particular, the motivation and manner of behavior of the offender, especially if the offense was committed to the detriment of a person who is vulnerable due to age or health, the commission of the offense jointly with a minor, the type and degree of violation of the obligations incumbent on the offender, the type and extent of the negative consequences of the offense, the characteristics and personal conditions of the offender, the way of life before committing the offense and the behavior after committing the offense, especially the efforts to repair the damage or otherwise compensate the social sense of justice, and the behavior of the victim.
I suspect that in other European countries the regulations are very similar (e.g. section 46(2) of german StGB).