Here is my answer, which is basically an expanded version of Greg Graviton's answer.
The question of why one can treat position and velocity as independent variables arise in the definition of the Lagrangian $L$ itself, before one thinks about varying the action $S:=\int_{t_i}^{t_f}dt \ L$, and has therefore nothing to do with calculus of variation.
On one hand, let us consider first the role of the Lagrangian.
Let there be given an arbitrary but fixed instant of time $t_0\in [t_i,t_f]$. The (instantaneous) Lagrangian $L(q(t_0),v(t_0),t_0)$ is a function of both the instantaneous position $q(t_0)$ and the instantaneous velocity $v(t_0)$ at the instant $t_0$.
Here $q(t_0)$ and $v(t_0)$ are independent variables. Note that the (instantaneous) Lagrangian $L(q(t_0),v(t_0),t_0)$ does not depend on the past $t<t_0$ nor the future $t>t_0$. (One may object that the velocity profile $\dot{q}\equiv\frac{dq}{dt}:[t_i,t_f]\to\mathbb{R}$ is the derivative of the position profile $q:[t_i,t_f]\to\mathbb{R}$, so how can $q(t_0)$ and $v(t_0)$ be truly independent variables? The point is that one is still entitled to make two independent choices of initial conditions.) We can repeat this argument for any other instant $t_0\in[t_i,t_f]$.
On the other hand, let us consider calculus of variation.
The action functional $S[q] := \int_{t_i}^{t_f}dt \ L(q(t),\dot{q}(t),t)$ depends on the whole (perhaps virtual) path $q:[t_i,t_f]\to\mathbb{R}$. Here the time derivative $\dot{q}\equiv\frac{dq}{dt}$ do depend on the function $q:[t_i,t_f]\to \mathbb{R}$. Extremizing the action functional
$$0=\delta S = \int_{t_i}^{t_f}dt\left[\left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}\right|_{v(t)=\dot{q}(t)} \delta q(t) +\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}\right|_{v(t)=\dot{q}(t)}\delta \dot{q}(t)\right] $$
$$ = \int_{t_i}^{t_f}dt\left[\left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}\right|_{v(t)=\dot{q}(t)} \delta q(t) +\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}\right|_{v(t)=\dot{q}(t)}\frac{d}{dt}\delta q(t)\right] $$
$$ = \int_{t_i}^{t_f}dt\left[\left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}\right|_{v(t)=\dot{q}(t)} - \frac{d}{dt}\left(\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}\right|_{v(t)=\dot{q}(t)} \right)\right]\delta q(t) $$
$$+ \int_{t_i}^{t_f}dt\frac{d}{dt}\left[\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}\right|_{v(t)=\dot{q}(t)}\delta q(t)\right] $$
with appropriate boundary conditions leads to Euler-Lagrange equation,
$$
\frac{d}{dt}\left(\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}
\right|_{v(t)=\dot{q}(t)} \right)
= \left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}
\right|_{v(t)=\dot{q}(t)}
$$
Note that $\frac{d}{dt}$ is a total time derivative, not an explicit time derivative $\frac{\partial}{\partial t}$, so that Euler-Lagrange equation is really a second-order ordinary differential equation (ODE),
$$\left(\ddot{q}(t)\frac{\partial}{\partial v(t)}+\dot{q}(t)\frac{\partial}{\partial q(t)}+\frac{\partial}{\partial t}\right) \left. \frac{\partial L(q(t),v(t),t)}{\partial v(t)}
\right|_{v(t)=\dot{q}(t)}
= \left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}
\right|_{v(t)=\dot{q}(t)} $$
To solve for the path $q:[t_i,t_f]\to \mathbb{R}$, one should specify two initial conditions, e.g., $q(t_i)=q_i$ and $\dot{q}(t_i)=v_i$.