The Ace Attorney/Gyakuten Saiban games are the original works, and as such are significantly older, and cover a longer story, so they would be considered the core cannon.
That said, there are not a lot of differences between the two - the cases covered in the anime are the same as in the games (so far the anime is up to the second case of the second game, although it skipped the first case of that game since it was more of a tutorial and not particularly important in the scheme of things), and the plots are pretty much the same. The anime does add a few details here and there, and in particular episode 13 gives some background to a big event when the main character was very young that does affect how one side character is portrayed slightly.
That said, if you just watch the anime, you will get the same story, you'll just have to wait longer to run into certain characters and plotlines.