They both mean court and can be used to talk about court/the courthouse. BUT the following are the more natural usages.
법정
If I said I’m going to 법정, that means I’m going to a trial, I’m on trial, I’m a witness, or something of the sort.
This is more general ‘court’ and can also be used to refer to the courtroom itself.
법원
If I said I was going to 법원 then I’m going to the courthouse in general. It generally insinuates that I’m going to the building itself, or a place bigger than just the courtroom.
This is ‘courthouse’, or the building itself.
~ Hannah