When there is an injury to the blood vessel, proteins are produced which attract platelets and other clotting factors resulting in the formation of a clot that can plug the injury to the blood vessel and helps in healing.
These blood clots can sometimes even form in the absence of an injury, which is potentially dangerous as the clot can restrict the blood flow within the blood vessels which can lead to a complication like a stroke or a heart attack.