In mathematics, $|\vec{x}|$ is used to describe the magnitude of a vector. When I started graph theory, I noticed the same notation $|V|$ to describe the size of a graph (amount of vertices). These two notations are very similar and have obvious ambiguity associated with it. One means give me the amount of elements list while the other means give me the sum of the elements squared.
How does one make sure that these two are not mixed up?
It is confusing. If you are a programmer, the notation is "type dependent". Here is the notation I am most familiar with:
If $\vec{x}$ is a vector, $||\vec{x}||_p$ means its $p$-norm (where $p=2$ is the standard Euclidean case you mentioned). Often, people conventionally use $|\vec{x}|=||\vec{x}||=||\vec{x}||_2$.
If $a\in\mathbb{R}$, then $|a|$ means absolute value
If $A$ is a matrix, $|A|$ means $\det(A)$ often, and $||A||_k$ refers to the induced or operator norm. (Personally, I prefer the practice of using $\det(A)$ for determinant and let $|A|$ mean the matrix $A$ with each element replaced by its absolute value, so that $|A|_{ij}=|a_{ij}|$).
If $S$ is a set, then $|S|$ is the cardinality of the set. (This is the case for graph theory, where $G=(V,E)$ and $V$ is the set of vertices; hence, $|V|$ is its size.)
For some tensors (e.g. in the physics of elasticity), $||T||=\sqrt{T:T}$ denotes a sort of magnitude