I thought exactly the same thing when I saw that scene. If you look at it again - the white woman opposite gives him a funny look - probably a disproving look.
Maybe due to the fact that they were making a film, he was allowed in that carriage. I am, however, surprised that they film-makers put him in an integrated carriage - it was so out of line with the rest of the film and of that area at the time
The Civil Rights Bill of 1964 outlawed that kind of discrimination. This movie wasn't set in the past. It was set in the present which would have been 1966. The movie was filmed from September to December 1966. The book it was based on was released in 1965. I was born in 1967 in Georgia and the schools had been desegregated for years before I started kindergarten in 1972. Discrimination and segregation on trains, in restaurants, theaters and other public places had been outlawed by this bill, too.
It doesn't mean that there wasn't still prejudice and racial tension between blacks and whites at the time, because there was and this movie shows that, but it was illegal to segregate public places based on race.
Title II
Outlawed discrimination based on race, color, religion or national origin in hotels, motels, restaurants, theaters, and all other public accommodations engaged in interstate commerce; exempted private clubs without defining the term "private."
1-The 1964 Civil Rights Act outlawed segregated travel accomodations, although that didn't quickly transform all southerners into smiling accomodationists.
2-Segregated interstate busses (and facilities) had been technically outlawed years earlier by the U.S. Supreme Court, although rarely adhered to. The Freedom Riders on busses in the early 1960's were challenging segregation but adhering to the law.
3-This movie takes place in 1966 or 1967, at a point in time when some bigotted white southerners like Gillespie knew things had changed via the 1964 Act. Gillespie might not have liked the changes, but he begrudgingly accepted them, or at least was not fiercely resistent.