Q:

How is buying gold during a recession helpful for the economy?

As far as I can see it, it is a selfish and fearful reaction to bad market conditions that would result in greater deflationary pressure. It is true that it preserves the owner's wealth, but unless the wealth could be used productively to mitigate the effects of the recession, shouldn't policymakers want to come up with something that makes people less likely to put their money into gold?
Edit:
To make the question clearer, this question aims to probe on the decision of investors of buying gold during bad times, and the supposed hypothesis that doing so would make things worse. The hypothesis of buying gold to be deflationary is because people are hiding wealth for the short term instead of investing or consuming.
I do not imply the assumption that policymakers should encourage investors to buy gold. Rather, the opposite -- policymakers should try to get investors off gold during bad times.
Given these conditions to be the case, I want to know if there is any better reason to own gold during bad times other than selfishness and fear among investors?

A:

From short-run macroeconomic perspective buying gold is neither  helpful nor unhelpful for an economy during recession.
Buying gold as opposed to buying something else just creates shift in demands between the sectors but it does not change aggregate demand overall. At the same time buying gold instead of buying something else can change the relative prices across the economy but not aggregate price level.
Your 'hypothesis'

of buying gold to be deflationary is because people are hiding wealth for the short term instead of investing or consuming

has no base in standard economic thought.
First, buying gold cannot be neither consuming nor investing. You cant have it both ways. Either you view purchase gold as a consumption $C$ or investment $I$ if you view it as saving. Regardless of which of the two ways you view it will not have any impact on aggregate demand. For example, following simple IS-LM AS-AD model from Blanchard's et al. (2010) Macroeconomics: European Perspective, the simple goods market equilibrium assuming linear consumption function will be given by
$$Y= \frac{1}{1-c_1} \left( c_0 + I + G-c_1 T \right)$$
Where, $c_1$ is the marginal propensity to consume, $c_0$ autonomous spending, $I$ investment, $G$ government spending and $T$ taxes.  Regardless of whether you assume in your situation that buying gold should belong to investment or consumption (and it has to belong somewhere, the above equilibrium condition is based on accounting identity that ultimately tracks all output including that of gold) and regardless whether you assume that the shift was from consumption or other investment it will not matter as both consumption and investment have the same multiplier $\frac{1}{1-c_1}$.
Saving in recession in form of hoarding cash can lead to the paradox of thrift as in the short during recessions when people try to save in such way "their income decreases by an amount such that their saving is unchanged" (Blanchard et al, 2010). But if you actually spend the money on something even as frivolous as just buying bars of gold the same wont hold as your spending increases the incomes of gold sellers/producers. This does not mean that its a net benefit as incomes of other people you would otherwise spend the money on shrink by the same amount so there is no net advantage to buying gold as compared to hot-dogs but there is neither any net disadvantage.
Next, there is no reason why buying gold instead something else should have any effect on price level and be either inflationary or deflationary. By standard quantity theory of money the price level is given by the following relationship:
$$P=\frac{MV}{Y}$$
Where $P$ is the price level, $M$ money supply, $V$ velocity of money, and $Y$ real output. We already established that $Y$ wont change in the first half of this answer. $M$ in a fiat monetary system is completely independent of gold supply. Your 'hypothesis' could have some actual relevance in a country that has fully commodity monetary system with money required to consist from actual gold but even there you would have to modify it to make the change in money supply to stick as changes in money supply that are just temporary and expected to be reverted soon wont have impact on $P$ as in more advanced versions of the above model also expectations matter (see Krugman et al., 1998).
Lastly, velocity is the frequency at which units of currency are used in economy. Stuffing money under the mattress instead of consuming or investing in a company reduces velocity of money because some units of currency are essentially taken out of circulation as long as they are kept under the mattress so velocity must drop. However, if you purchase gold with your money instead of something else you are not taking money out of circulation. You are just making choice of giving the money to producers and sellers of gold (i.e. miners, owners of mines and their employees) as opposed to giving it to producers and sellers of something else lets say car manufactures and sellers. The money will still circulate and unless you can empirically argue that gold producers are more likely to stuff the money they get for your gold under the mattress or in other ways people from those industries reduce the frequency in which currency circulates compared to car manufacturers there is absolutely no basis for claiming that purchase of gold would affect velocity. Hence purchase of gold as opposed to car or something else would not be expected to change $P$ and thus lead to either inflation or deflation.
Thus to sum up, the whole premise on which your question is based does not make any sense given established knowledge about macroeconomics and buying gold as opposed to something else should be expected to be from macroeconomic perspective neutral.

