For the base, the 18 is fine, use 2" nails. You'll lose an inch in the molding and Sheetrock, just mark the stud locations, 1" into the studs will hold well.
For the crown it depends. If you put up a backer strip, you can get by with 2" nails, 18 ga will work fine. I shoot one up nearly vertical into the backer and a second horizontally just above. I found out the hard way it's more than strong enough when I had to pull a piece out to reposition it. Without a backer, I would step up to 2.5" 16 ga nails.
The 18's are preferred because they leave a smaller cleaner hole, but when you need more than 2" of nail, the thicker gauge gives you that.