As far as I know you get one or the other. You get the hats when donating books to the school teacher. There may be a way to do it if you can manage to hero save after getting one or the other and then going back and donating the opposite type of book, the next time around... but you'd have to find a way to get into bowerstone while actually still in a mission area in order to hero save.
Think you can only get either the good or the evil one. At a certain point the teacher will inform you that he has enough books (after u got one hat or after a certain number of books, don't know, haven't tested).