you need to choose 은/는/이/가 based on the case if the word that comes before 은/는/이/가 has "받침" or not. 나 is the word without 받침 but 난 has 받침. 사'과', 아'기', 남'자', 여'자' have no 받침 but 공'책', 연'필', 핸드'폰' have 받침.
so you need to read a lot of articles.
But, there is another way how you use 은/는/이/가.
When you see the word that can come before both 은/는 and 이/가, you should figure out what the speaker want to say. if specially you see 은/는, you should find hidning meaning of it.
책이 많아요.=we have lots of books.
책'은' 많아요=we have lots of books...................but.......(we dont have pencils....etc)
나는 사과가 좋아: I like apples.
나는 사과'는' 좋아: I like apples but......................( I prefer grapes...)