Functional Derivative of action

Let me give a pedagogical answer. You're confused about the functional derivative

$$ \frac{\delta}{\delta \phi(y)}\int dx\, \phi(x) \partial^2 \phi(x).$$

We can compute such derivatives by perturbing a functional:

$$ F[\phi + \epsilon \chi] = F[\phi] + \epsilon \int dx \, \frac{\delta F[\phi]}{\delta \phi(x)}\chi(x) + O(\epsilon^2).$$

Now let $F[\phi] = \int dx\, \phi(x) \partial^2 \phi(x)$. Then

$$ F[\phi + \epsilon \chi] - F[\phi] = \epsilon \int dx \left[ \chi(x) \partial^2 \phi(x) + \phi(x) \partial^2 \chi(x) \right] + O(\epsilon^2). $$ But this is not of the correct form, due to the $\partial^2 \chi(x)$ term. However, you can always integrate by parts (exercise): $$ \int dx \, \phi(x) \partial^2 \chi(x) = \int dx \, \chi(x) \partial^2 \phi(x) \, + \, \text{boundary terms}.$$ By assumption, the boundary terms do not contribute. Bringing everything together, we can rewrite the formula above as

$$ F[\phi + \epsilon \chi] - F[\phi]= 2 \times \epsilon \int dx \, \chi(x) \partial^2 \phi(x) + O(\epsilon^2).$$ At this point, we conclude that

$$ \frac{\delta F[\phi]}{\delta \phi(x)} = 2 \partial^2 \phi(x). $$