There is great debate on origin of word "tartan." It could have come from Irish "tarsna", which meant crosswise, or Scottish Gaelic "tarsuinn", meaning across. Or it could simply mean cloth, from old French "tartaine". What we know is, long before there were individual Scottish clans and tartans, Celts loved bright colors and patterned cloth. Later Scots incorporated this love for color into a unique plaid cloth. Only in recent history have particular patterns been associated with particular districts, army regiments, and, of course, Scottish clans.
Prior to around 1700, there is no historical reason to associate particular patterns with particular people or places, but it is clear that plaid cloth was made and worn throughout Highlands and had been for hundreds of years.
By 1746, clan tartans were so closely associated with Highlanders and clan loyalty that their wearing was banned by English after Scots' defeat at Culloden until 1782. Interestingly, this was time when many of famous Highland Regiments were being formed, and they were allowed to select and wear a regimental tartan (for example, Black Watch).
The idea may have been to wean loyalty away from clan and towards British empire. Some of these regimental tartans later became family tartans.