Although this wasn’t growing in a garden I don’t think it’s a wildflower. Rather I believe it’s a Dianthus barbatus, otherwise know as ‘Sweet William’, which originated in a garden somewhere and has been blown, carried by birds – who knows how – to where it is now growing.
According to Wikipedia:
Sweet William is a species of Dianthus native to southern Europe and parts of Asia which has become a popular ornamental garden plant. It is a herbaceous biennial or short-lived perennial plant growing to 13–92 cm tall, with flowers in a dense cluster of up to 30 at the top of the stems. Each flower is 2–3 cm diameter with five petals displaying serrated edges. Wild plants produce red flowers with a white base, but colours in cultivars range from white, pink, red, and purple to variegated patterns. The exact origin of its English common name is unknown but first appears in 1596 in botanist John Gerard’s garden catalogue. The flowers are edible and may have medicinal properties. Sweet William attracts bees, birds, and butterflies.
Sweet William is a herbaceous biennial or short-lived perennial plant native to the mountains of southern Europe from the Pyrenees east to the Carpathians and the Balkans, with a variety disjunct in northeastern China, Korea, and southeasternmost Russia. It grows to 13–92 cm tall (depending on the variety), with green to glaucous blue-green tapered leaves 4–10 cm long and 1–2 cm broad. The flowers are produced in a dense cluster of up to 30 at the top of the stems and have a spicy, clove-like scent; each flower is 2–3 cm diameter with five petals with serrated edges; in wild plants the petals are red with a white base.
There are two varieties:
Dianthus barbatus var. barbatus. Southern Europe. Leaves broader, up to 2 cm broad.
Dianthus barbatus var. asiaticus Nakai. Northeastern Asia. Leaves slenderer, not over 1 cm broad.
The Wikipedia article goes on to suggest how the name came about:
Many legends purport to explain how Sweet William acquired its English common name, but none is verified. “Sweet William” is often said to honour the 18th century Prince William, Duke of Cumberland. As a result of the Duke’s victory at the Battle of Culloden and his generally brutal treatment of the king’s enemies, it is also claimed that the Scots sometimes call the flower “Stinking Billy”. Though this makes a nice story, it is entirely untrue. The Scots sometimes refer to the noxious ragwort, as “Stinking Billy” in memory of the infamous Duke. Phillips speculated that the flower was named after Gerard’s contemporary, William Shakespeare. It is also said to be named after Saint William of York or after William the Conqueror. Another etymological derivation is that william is a corruption of the French oeillet, meaning both “carnation” and “little eye”. Sweet William is a favourite name for lovelorn young men in English folkloric ballads, e.g., “Fair Margaret and Sweet William.”