In context of this kind of discussion - weight and cost are the same thing - the more you spend on a bike, the lighter it is (with diminishing returns) and you cannot talk about weight without talking about how much money you have and are prepared to spend (sometimes not the same). The context of this answer is a targeted weight of a 7-8kg MTB.
No weight does not matter - or more accurately, it matters far less than most people imagine it does. If you are trying to build a 7-8kg MTB, a hair cut will be providing cheaper $/gram than bike upgrades. For most people, losing 1000g in body weight is cheaper than losing 1000g from your bike, as is gaining a little bit more fitness. Do you ever arrive home with water in your drink bottle, or snacks in your pocket - that 100mL of water is 100g you spent $100s to get the super light carbon bike.
A well coached rider on a heavy bike will out perform an unskilled rider on the lightest bike on any mountain bike trail. Learning to ride will increase your enjoyment, endurance and speed far more than spending money on a lighter bike, and unlike a lightweight bike, it's something that lasts a lifetime. For a vast majority of riders I have met, a weekend coaching session would provide immeasurable improvement in riding (speed, endurance and enjoyment) compared to the spending money saving weight - yet many people never spend a dime on coaching after forking out $1000s on a 'faster' bike.
Clearly at some point - you are a finely tuned elite athlete with no more body weight to lose, you have been coached till your riding form is used in reference videos, you have trained till there no more training you can do, a light bike becomes the only way to go faster. There is also the mid way - you want to go as fast as you can and a lighter bike will make an instant improvement, why not - if you have the cash, there's no reason not to.
However, other things come to play. They do not build light bikes with cheap bearings and poor quality shifting. Much of the gain attributed to weight is actually improved efficiency in the drive train, better geometry and in the case of MTB, shocks that get more energy into forward movement. Lighter bikes are usually less durable than slightly heavier bikes - sponsored riders do not care about it, but they are not the ideal bike for a weekend warrior
I am by no way advocating heading out and buying the heaviest bike in the shop. What I am advocating is looking at your own financial situation, your riding desires and being absolutely honest with yourself as to why you are aiming for a 7-8kg MTB. Probably the best advice I was once given (as a non competitive weekend warrior) was "Buy the heaviest bike your ego will let you ride".