Basic detached: $40-80/sq ft. With living space above: $80-150/sq ft. A 24×24 ft (576 sq ft) garage: $23,000-46,000. Concrete slab alone: $4-8/sq ft. Add $5,000-10,000 for electrical and garage door opener.
Detached costs 10-20% more: you're building 4 walls instead of sharing one with the house, plus separate electrical service and a longer driveway. Attached is cheaper and more convenient. Detached is quieter and better for workshops.