There is an odd connection between these things. Gothic architecture, which emerged in France during the middle ages, was a radical departure from the preceding, Romanesque style that dominated church design for hundreds of years. Architects like Suger, who designed the Basilica of Saint-Denis in Paris, discovered that the use of various buttresses and different styles of vaulted ceilings could allow churches to not only be built with incredibly tall walls, but with much larger windows to allow in more light than ever before. Before then, most churches were very squat, compact, and dark, made from simple barrel vaulted ceiling or just from wood. Additionally, the windows were so small since they were afraid that larger windows would put the stability of the whole structure in danger. Because of the radical departure from Romanesque architecture, some considered this new style to be absolutely repugnant, using the term Gothic as an insult since it referred to barbarian tribes that sacked the city of Rome.
Now, modern goth subculture does not directly get its name from the Gothic tribes or Gothic architecture, but there are a couple degrees of separation. Goth subculture got its name as a reference to Gothic literature that was popular in the nineteenth century. The works of Edgar Allan Poe, Mary Shelley, and Bram Stoker fall into this category. Nowadays, it refers to stories that make up the foundation blocks of the horror genre. However, the literary style was given the term Gothic as a reference to the popular setting of the Gothic castle or cathedral, like in The Castle of Otranto by Horace Walpole.
So, to sum it all up, a new style of French architecture was seen as ugly and barbaric, which led to some people referring to it as Gothic as an insult. Later, in the nineteenth century, authors of horror fiction used the setting of buildings built in the Gothic style for their stories, leading to the development of Gothic literature. This then conflated the term Gothic with the dark, the mysterious, the macabre, etc., leading to where Gothic subculture finds its name.