The ability of markets and prices to direct resources to higher valued uses: Is this a short run or a long run attribute? I came across the following quote in a lecture:

&quot;In economics, we often talk about the power of markets and prices to
direct resources to higher valued uses.&quot; - Mike Munger

Is this ability of the markets to direct resources to higher valued uses considered to come into effect in the long run or the short run?

Everything below this point has been edited keeping the comment of user:Giskard in mind.

I suspect it is a long-run attribute of markets for the following reason:
Imagine that two firms A and B are bidding for raw materials. Society values the good of firm A more highly than that of firm B, and therefore is willing to pay more for the former than for the latter. In the short run, there may be discrepancies in their respective efficiencies, such that A is less productive and therefore less profitable than B. In the long run, A can adjust its methods of production and &quot;catch up&quot; with B in terms of profitability, thereby ensuring that it is able to outbid B (remember that society is willing to pay more for A's output). To me, it looks as if only in the long run can the resources be seen to be allocated according to its highest value to society, due to the above reasoning. Is this argument a sensible one?
No its not necessary long run phenomenon it can hold in short run as well. Rather what matters is how competitive markets are and whether there are any market failures such as externalities etc.
To be even more specific under the first theorem of welfare economics if markets are competitive, complete, information is symmetric, there are no externalities and there are no transaction costs or in general there is an absence of any market failure, then any general equilibrium in competitive markets will be Pareto-efficient.
Pareto-efficiency requires that all resources are allocated to their highest valued uses as if there would be any unexhausted potential gain from trade (i.e. a situation where two individuals each have something they do not value more than what other individual has) two individuals could increase their utility further by actually doing the trade and so the outcome would not be Pareto-efficient.
However, in real life of course the first welfare theorem fails due to market failures and other reasons. In that case market might fail to allocate resources to its most valued uses. Some of the problems might have an effect mainly in the short run and in long run they might still be efficient, but in other cases they wont. In the case you describe the two firms are actually not perfectly competitive but engaged in some monopolistic competition. In monopolistic competition market indeed wont allocate resources to their most efficient uses always in the short-run as firms will have some excess capacity (see Mankiw Principles of Economcis for example) which may imply that not all resources are employed to their most valued uses. But even here I would have to add caveats on that the result would change depending on whether we assume competition occurs on price or quantity and so on.