This is what computer scientists would call (ad-hoc) polymorphic or “overloaded” functions: basically, an operator $X$ on the Hilbert space $\mathcal{H}$ is not just one function $X: \mathcal{H}\to\mathcal{H}$, but a family of two functions
$$
X = \{ X_{\mathcal{H}}, \quad X_{\mathcal{H}^\ast} \}
$$
with
$$
X_{\mathcal{H}}: \mathcal{H}\to\mathcal{H}, \quad X_{\mathcal{H}^\ast}: \mathcal{H}^\ast\to\mathcal{H}^\ast
$$
Since a Hilbert space's dual space (the “space of bra-vectors”) is a different space from $\mathcal{H}$ itself, it's always unambiguous which of the two functions you mean when applying $X$ to either a ket or a bra.
And the definition of $X_{\mathcal{H}^\ast}$ follows directly from the one of $X_{\mathcal{H}}$ vice versa. This is easy to see in one direction:
$$
\bigl(X_{\mathcal{H}^\ast}(\langle f|)\bigr)(|v\rangle) = \langle f| \bigl(X_\mathcal{H}(|v\rangle)\bigr)
$$
In the other direction, we need to invoke the Riesz representation theorem: for any $|v\rangle \in \mathcal{H}$, let
$$\begin{align}
\langle X_v^\ast| & \in\mathcal{H}^\ast
\\ \langle X_v^\ast| &:= X_{\mathcal{H}^\ast}\bigl(\langle . , v\rangle\bigr).
\end{align}$$
where by $\langle . , v\rangle$ I mean the function
$$\begin{align}
v^\ast & \in \mathcal{H}^\ast
\\ v^\ast(w) & := \langle w,v\rangle
\end{align}$$
(This is now not an application of dual-vectors, but the actual scalar product that comes with the Hilbert space!)
Then Riesz tells us that this corresponds to one unique element $X_v\in\mathcal{H}$, so we can define
$$
X_{\mathcal H}(|v\rangle) := X_v.
$$
And because physicists are lazy (good trait, although some overdo it), they avoid all the “obvious” parentheses etc., and just assume the reader will know how the operator needs to be applied, which space it lives in, etc.. Swapping between a bra- and a ket-version of a state implicitly always invokes the Riesz representation theorem, but this is seldom talked about.