The “guard” button (the blue one) keeps them in a set area until you dismiss the guard flag or they desperately need to go eat/sleep. It’s ideal for mustering your army together before sending them into combat.
Make sure their jobs aren’t disabled (either individually, or having the jobs column un-ticked), this will cause them to ignore all commands. Also, be aware that if the CPU is over-strained, hearthling AI is one of the first things to go. Any task which involves pathfinding is fairly expensive to compute and thus has a higher chance of being ‘dropped’ if the CPU is doing too much work (it will work on each task for so on, and then return an automatic ‘fail’ if it’s taking too long so that the whole game doesn’t get traffic-jammed behind that calculation); although this shouldn’t be an issue if everything else is running smoothly there’s a chance you’re getting spikes of CPU use and everything goes back to normal quickly after, but those tasks attempted during the spike quietly fail.
Putting all your soldiers in a single party is another thing which makes it more difficult for the game to process their tasks, since more units have to stay together at once. I’ve found that when I have more than 6 soldiers, it works better to start splitting them up into multiple parties. I like to have a party of knights and clerics, and another with my archers and footmen – the “tanky” party goes in first to draw aggro, and the “DPS” party follows behind so their more fragile members don’t get targeted.
If you’re getting lots of cases where soldiers outright ignore orders, it’s probably a good idea to upload a copy of the save file so that the developers can take a look (probably mark it as a bug report so it’s easier for them to see)