Alma knows these things because he has been “born of God,” a phrase he picks up in the corresponding chiastic verse 26, when he remarks that he’s not the only one who has attained this knowledge but is one of many who have been born of God because they have personally experienced (tasted and seen) God’s goodness.