[deleted]
Your question is a good one but unfortunately has no one specific answer - "why do humans break the rules they write and preach" is an interesting question, and one as old as history itself!
An important bit of context to your question is that we know that the Bible prohibits killing today, but pre-Printing press, there wasn't too much in the way of common Religious texts and pamphlets, and literacy was definitely less ubiquitous than it is today. An average peasant that couldn't read too much may have a vague fear of God, and some idea of bits of the moral code, but mainly had to get their Scripture from their more learned clergyman at Mass. So that's one of the more overall issues of Biblical knowledge.
In regards to the above, Christian teaching mainly came from sources of ecclesiastical authority of some sort. And the ultimate authority is the Papacy itself in Rome. The Pope himself was referred to literally as the Vicar of Christ (though that title was somewhat inconsistent for a while). He was Christ's representative on earth - and the bishops and priests were the Pope's representatives. Faith generally followed then as a top-down, dictated experience, rather than a real personal journey, due to the Catholic Church's huge amount of power and influence over Europe before the Protestant Reformation.
But the Church was composed of humans, and humans are of course corruptible and will sin. Christian faith teaches that all sins can be forgiven through the grace of God, hence the Catholic sacrament of Reconciliation, a sort of transactional exchange where you tell a priest your sins (you must be genuinely contrite), he may give you a sort of penance to perform, and you are absolved of sin after satisfaction or penance. Even a mortal sin such as murder could be forgiven by God.
And the Catholic Church for much of the Middle Ages, barring the occasional kerfuffle or schism, was extremely rich and powerful and woven deep into European politics. All of this leads to the inevitability that even the Vicar of Christ and his representatives will sin. These sins will include violence, war, political corruption, and greed. Some sins are directly tied to expanding and keeping the Church's political power - the violent Spanish Inquisition, for example, or general persecution of heretics or other faiths (which you touch upon mentioning the Crusades). In summary, Popes, Bishops, inquisitors, etc. can commit what are grievous sins in Catholic and Christian teaching in their political roles, and theoretically can be forgiven for these same sins via Sacrament.
But you ask of the average person and not these high-and-mighty priests, bishops, and popes. We can't really read the mind of an average person in the middle ages - but let's look at someone who came from a fairly humble middle-class background whose life was steeped in religious conflict and rose to became an extremely larger-than-life figure - Joan of Arc.
Joan of Arc has a pretty wild story and its somewhat difficult to separate the myth and propaganda from the real woman - but by all accounts she grew up in an Eastern French village where she attended Mass. According to her, this is where she first saw her famous visions, who she identified as Saint Michael, Saint Catherine, and Saint Margaret (She was said to have seen and heard divine figures and voices throughout her life - the full picture of her visions or possible mental condition is a matter of debate and can never be conclusively answered). Long story short, she became inspired in some way to join the Hundred Years' War (1337-1453) between the English and French (both Christian nations) and swiftly became a source of inspiration for the French in this conflict. She also near-singlehandedly injected heavy religious overtones into the conflict via her alleged divine inspiration, and allegedly provided both strategic insight and a hefty morale boost to both soldiers and the general French populace.
So, how did Joan herself justify being part of a war where people were being murdered, and herself threatening to bring violence upon the English and ordering siege bombardments? Let's look at some letters she dictated or approved of (she was famously illiterate and only just started learning to write before she was executed by the Church):
Here's one to the English on March 22, 1429:
"King of England, and you duke of Bedford, who call yourself regent of the kingdom of France; you, William Pole, count of Suffolk; John Talbot, and you Thomas Lord Scales, who call yourselves lieutenants of the said duke of Bedford, make satisfaction to the King of Heaven; surrender to the Maid who is sent here by God, the King of Heaven, the keys of all the good towns which you have taken and violated in France. She is come here by God’s will to reclaim the blood royal. She is very ready to make peace, if you are willing to grant her satisfaction by abandoning France and paying for what you have held. And you, archers, men-at-war, gentlemen and others, who are before the town of Orléans, go away into your own country, in God’s name. And if you do not do so, expect tidings from the maid, who will come to see you shortly, to your very great harm. King of England, if you do not do so, I am a chieftain of war, and in whatever place I meet your people in France, I shall make them leave, and in whether they will it or not. And if they will not obey, I will have them all put to death..."
You can read her letters at https://www.jeanne-darc.info/biography/letters/.
The letter continues, largely to the same tone: Get outta here or I will wreck you as the Lord wills it. A part later in the letter stands out to me: "You, duke of Bedford, the maid prays and requests that you do not bring destruction upon yourself." Joan is essentially saying in her language that THEY would bring destruction on THEMSELVES should they resist. She, believing herself or portraying herself to be God's will, puts the sin on the English for their continued opposition, and rationalizes any of their deaths that follow as a natural consequence of God's will rather than the actions of her fellow soldiers and commanders.
This may be logical with Christian teachings because the Old Testament God is famously fairly wrathful, visiting His violent punishment on entire cities, armies, or tribes. It is possible Joan could have heard of some of these stories during her village masses and did not view God's wrath upon an army as incompatible with what she had heard. By equating killings committed by her fellow soldiers (she herself was said to not personally kill) to God's wrath, and attributing her own words and threats of violence to God's will, she may be distancing the sin from the sinner in that way.
There's another scathing letter to the Hussites on March 23, 1430. Take this one with some salt though, because it was written in Latin by a priest and Joan may have just approved it rather than dictated it. If she approved it, it showed Joan thought none too fondly of who the Catholic deemed heretics. It's basically three paragraphs telling the Hussites that they're wrong and bad, and if Joan weren't so busy with these English, she'd go body them herself. Here's the second paragraph:
"What is this frenzy? What rage or madness drives you? This faith, which Almighty God, which the Son, which the Holy Spirit have revealed, established, given sway and glorified a thousandfold through miracles is the faith which you persecute, which you wish to overturn and obliterate. You yourselves are blind, but not because you’re among those who lack eyes or the ability to see. Do you think that you will not be punished for this? Or do you not realize that God will block your criminal efforts? Do you think He will allow you to remain in darkness and error? The more you give yourselves over to criminal sacrilege, the more He will ready great punishment and torment for you."
Again, God is the main instrument of the wrath in this paragraph.
The above are only two examples of letters dictated or approved of by one person that may give some insight into her justifications for war against fellow Christians. Christian teaching is that God is perfect and all-loving, but to be human is to sin, and as such even His representatives on Earth may fall to corruption and sin, as is well-documented throughout the Church's actions throughout the Middle Ages.
I also want to add a little to the already long response that gave great detail on some of the general problems and specificities of the later middle ages.
This are just some examples, but I hope they give an additional view on your question. The handbook I used for the crusading part is not in English but I will instead provide some material on the peace of god:
Geoffrey Koziol, The Peace of God, Leeds 2018.
Thomas Head [ed.], The Peace of God. Social Violence and Religious Response in France around the Year 1000, Ithaca 1992. (available on googlebooks)