D'Enghien was tried and found guilty by a court-martial which was a legal court. Hofer was tried and convicted by a court-martial. Interestingly, he was betrayed by his neighbor. Treason was taken quite seriously in the early 18th century, as was armed rebellion.
Early 21st century moralization tends to have a much softer outlook on both treason and capital punishment, unfortunately.