Monasteries did get attacked fairly frequently during the mediaeval and early modern period, there are numerous examples from the Viking Wars, the 100 Years War, the Anglo-Scots wars, the French Wars of Religion, the 30 Years War, and many others.
They were tempting targets for any marauding army. Many abbeys were extremely wealthy, but even poor monasteries had a standard of living equal or rather better than that of neighbouring aristocrats which made them appealing for looting. On the menu would be the church plate, vestments, relics (very saleable), books, cash (not only that belonging to the monastery, but funds belonging to local nobles, who often used monasteries for safe deposit of their treasure and even deeds), industrial commodities like wool from the abbey estates and a variety of nickable household goods.
Another attraction was food, always appealing to an army. Monasteries kept a lot of food, drink and livestock on hand, to feed the community and meet their duty of hospitality to travellers. Many houses also received rents in agricultural produce, so that surplus might also be there for the taking.
Another threat was civic unrest. Monasteries were often unpopular with their neighbours, and tenants. They were frequently high-handed and arrogant, and often grasping landlords. One example would be the powerful Benedictine abbey of Bury St Edmunds in Suffolk, UK. The abbey was constantly at odds with the citizens of the town of Bury outside the gates. The citizens considered the abbey an oppressive landlord (which it was, to be fair) and there was frequent fighting between the monks and the citizens; the latter laid siege to and sacked the abbey in 1327 and again 1381. Another example would be the Cistercian abbey of Vale Royal in rural Cheshire which was at war with both its tenants and neighbouring gentry for almost two centuries and was the scene of much violence, including the abbot being murdered by neighbours on two separate occasions (1339 and 1437).
Church politics could also cause violence. Mediaeval and early modern monks and nuns were mostly drawn from the aristocracy and gentry and, unfortunately, they behaved like it. Disputed elections to be head of the house could cause fighting, as seen at the rich Cistercian abbey of Fountains (Yorkshire, UK) where a disputed election in 1410 caused a local civil war in the area lasting into the 1430s. Mercenary troops hired by one of the candidates, Roger Frank, besieged and sacked the abbey in 1423. This was a proper siege, with Roger's soldiers using scaling ladders to assault the abbey.
Rival institutions could also be a problem. For example in the city of Colchester (Essex, UK), the clergy of St Botolph's Priory (Augustinian canons) and St John's Abbey (Benedictine monks) hated each other passionately, and were constantly fighting each other with the help of the citizens. They would attack each other's monasteries, most notably in 1363, when the St Botolph's canons besieged St John's. This particular scandal was reported all the way up to King Edward III and Pope Urban V, who finally squashed their nonsense.
On fortifications, some monasteries, especially in unsettled areas vulnerable to war, did have quite powerful fortifications, there are a number of great standing examples across Europe. The majority did not have any fortifications, with the monastic precinct usually being enclosed depending on the area by a high but unfortified wall, a moat, or both. That said, as massive, strongly built complexes of masonry, often in strategic locations or on defensible sites like high hills, even unfortified monasteries have often been taken over and used for military purposes and fortresses. One thinks of the fate of the abbey of Monte Cassino in Italy in that horrible 1944 battle