vikinghank: why is this happening, and can I avoid it?
HereForTheBeer is correct; there is a bug if you distribute stat points, but do not apply the changes, then save the game and reload. That will result in the stat points being lost.
You can use
iZakaroN's SaveEditor to replace the stat points, though.
When you first open the stat window, there is an X close button near the bottom, possibly hidden behind the toolbar UI interface if you are playing on lower resolutions (in that case, left click and hold to drag the window up). After you distribute stat points, the button turns to a checkmark to confirm those choices.
screenshot of the stat window (showing initial, levelled, distributed and confirmed stats)
If you wait long enough for any food/potion/spell effects to wear off and remove all equipment with stat bonuses (or make sure to take them into account), then the sum of
strength + agility + intelligence + constitution + any unassigned stat points
should be equal to
40 + 5*(Character Level) + other bonuses you would not have reached yet at low levels