As TFA says, they were specifically looking for the effect. It an "HDAC inhibitor." These uh, inhibit the enzyme HDAC, which is known to shut down brain plasticity in adult (mice). As to why they figured that out, some of the studies cited in TFA were looking at brain plasticity, plaques, brain damage (strokes?) and (of course) Alzheimer's.
BTW, one of Sodium Valproate's trade names is Depakote. Very commonly prescribed (or at least used to be) for treatment of bipolar disorder and epilepsy.
Not sure we know exactly how valproic acid works. HDACs are like master regulators. Histone acylation is kind of like the opposite of DNA methylation. It is a marker of active transcription. So messing around with these can lead to big epigenetic changes (i.e. state of the genome) in impacted cells / tissues.