See this excellent paper by @MarkJoshi which defines/discusses the use of power numeraires.
Starting from a dynamics specified under the risk-neutral measure $\mathbb{Q}$
\begin{align}
&\frac{dS_t}{S_t} = (r-q) dt + \sigma dW_t^{\mathbb{Q}}\\
\iff& S_T\ \vert\ \mathcal{F}_t = S_t e^{(r-q-\frac{\sigma^2}{2})(T-t) + \sigma(W_T-W_t)} \tag{EQ.0}
\end{align}
Let us consider the asset (power numéraire)
\begin{align}
N_{t,T} :=&\ \ e^{-r(T-t)} \mathbb{E}^{\mathbb{Q}} \left[S_T^2\ \vert\ \mathcal{F}_t \right] \\
=&\ \ S_t^2 e^{\left( r - 2q + \sigma^2 \right)(T-t)} > 0, \forall t \tag{EQ.1} \in [0,T]
\end{align}
and define the unique equivalent martingale measure $\mathbb{Q}^N$ which uses this asset as numéraire.
From the Girsanov theorem (or using the rationale described in the aforementioned paper), it is straightforward to infer the dynamics of the risky asset $S_t$ under the measure $\mathbb{Q}^N$
$$ \frac{dS_t}{S_t} = (r - q + 2\sigma^2) dt + \sigma dW_t^{\mathbb{Q}^N} \tag{EQ.2}$$
since the Radon-Nikodym happens to compute as
$$ \left. \frac{d\mathbb{Q}^N}{d\mathbb{Q}} \right\vert_{\mathcal{F}_T} = \frac{N_{T,T}\ B_0}{N_{0,T}\ B_T} = \frac{S_T^2}{N_{0,T}\ e^{rT}} = \mathcal{E} \left( 2\sigma W_T^{\mathbb{Q}} \right) \tag{EQ.3} $$
where the notation $\mathcal{E}(X_t)=\exp(X_t-\frac{1}{2}\langle X,X \rangle_t)$ denotes the stochastic exponential.
Now, the price of square-or-nothing option can be evaluated as
\begin{align}
V_0 &= e^{-rT} \mathbb{E}^\mathbb{Q} \left[ \frac{S_T^2}{K} \pmb{1}_{\{ S_T \geq K \}} \ \vert\ \mathcal{F}_0 \right] \\
&= e^{-rT} \mathbb{E}^\mathbb{Q^N} \left[ \frac{S_T^2}{K} \pmb{1}_{\{ S_T \geq K \}} \left(\frac{d\mathbb{Q}^N}{d\mathbb{Q}}\big|_{\mathcal{F}_T}\right)^{-1}\ \vert\ \mathcal{F}_0 \right]\ \ \ \text{(change of numéraire)} \\
&= N_{0,T} \mathbb{E}^\mathbb{Q^N} \left[ \frac{1}{K} \pmb{1}_{\{ S_T \geq K \}}\ \vert\ \mathcal{F}_0 \right]\ \ \ \ \ \ \ \ \ \ \ \ \ \ \text{(use (EQ.3))} \\
&= \frac{N_{0,T}}{K} \mathbb{Q^N}(S_T \geq K)
\end{align}
At this stage, because we have shown in $\text{(EQ.2)}$ that $S_T$ was lognormally distributed under $\mathbb{Q}^N$, plugging the definition $\text{(EQ.1)}$ of $N_{0,T}$ finally allows us to re-write the above equation as
\begin{align}
V_0 &= \frac{S_0^2}{K} e^{\left( r - 2q + \sigma^2 \right)T} \Phi( d ) \\
d &= \frac{\ln \left(\frac{S_0}{K}\right) + \left(r-q+\frac{3}{2}\sigma^2\right)T }{\sigma\sqrt{T}}\\
\Phi(x) &= \mathbb{P}(X \leq x),\ X \sim N(0,1)
\end{align}
which is exactly the result given in @Gordon's answer and in Mark Joshi's paper, see middle of page 3.