A man has appeared in court charged with planning a terrorism act after entering the office of a New South Wales MP.