When a central bank tries to achieve price stability, it always has to make a trade-off between price stability and, consequently, better medium- to longer-term economic performance and short-term economic costs, either explicitly or implicitly, depending on exactly what its mandate is.
There is little that a central bank can do to control imported inflation. However, the longer high imported inflation persists, the more likely it is to feed into domestic inflation dynamics (via the production chain and price and wage formation). That's why central banks focus on (market and household) expectations of domestically generated inflation.
The higher the prospects for medium-term inflation in the absence of intervention, the more beneficial it is, in their view, to trade short-term costs for low medium-term inflation through intervention. In this sense, the aggregate (or net effect) of short-term costs and longer-term benefits is indeed positive, at least in their view, even if the short-term costs are substantial in absolute terms.
Given the lags with which monetary policy affects the economy (a rule of thumb is 6-18 months) and an inherently uncertain future (who in January 2022 would have expected Russia to invade Ukraine in February?) it is impossible for total inflation to always match the target.
This would only be "possible" if a central bank had perfect foresight, at least over the period in which policy affects the economy. In particular, it would have to be able to perfectly anticipate all external shocks, the way they are transmitted domestically, and the transmission of its own policies.
In this hypothetical situation, massive interest rate hikes would be needed to pre-empt an upward deviation of inflation from target. The reason is that the central bank would offset imported inflation by lowering domestic inflation proportionally, which would most likely be negative (depending on how high imported inflation is).
Example: Assume imported inflation is only due to energy imports whose prices have risen 42%, while domestic inflation runs at 2% Assume energy makes up 20% of the CPI basket. Without intervention that makes for 10% total inflation [$0.2\times42 + 0.8\times2 = 10$]. In order to achieve 2% overall inflation, domestic inflation would have to be -8% [$0.2\times42 + 0.8\times(-8) = 2$].
Since so much more policy tightening is required to bring total inflation, not just domestic inflation, under control, the intervention would have a much higher economic cost than if only domestic inflation were targeted. More importantly, it would be "overkill." An otherwise healthy economy can well tolerate an occasional increase in imported inflation as long as it is temporary.