This distinction of dividing languages based on prestige, political boundaries, and writing is too reductive to tell the whole story. Many languages cross political boundaries, such as French and Kurdish. Also, many other languages--especially indigenous languages--do not have their own countries and have not been declared an official language by any government, and yet are widely considered to be languages and not dialects. Lastly, a core tenet of linguistics is that writing is a nonessential byproduct of language; if writing was essential for a linguistic variety to be considered a language, then there are potentially thousands of languages that either do not use a writing system or existed before writing was invented that should be considered dialects instead--but they're not.
There are too many exceptions and counterexamples, therefore, for this sociopolitical definition to hold.
The other problem with this distinction rests on the concept of prestige. Typically, the dictionaries and grammars that dictate how a given language should be spoken are based on the high-prestige standard variant of that language while the other lower-prestige, stigmatized varieties are considered lesser, merely dialects that fail to meet that standard.
In other words, a "language" is viewed as the ideal, and every other linguistic variety within that language is considered a "dialect." Using prestige as a metric to decide what is a language and what is a dialect implies that if a linguistic variety is low-prestige, it is too simple, lowly, and unsophisticated to be considered a full-fledged language.