Much of this answer is based on the related answer How does sideslip indicator react during crosswind?.
We should start by understanding what the deflection of the "inclinometer" or "ball" actually indicates. To a good approximation, it responds to the net sum of all lateral (sideways) accelerations acting on an aircraft, excluding the lateral acceleration component due to gravity. By "lateral" or "sideways" we mean in the aircraft's own reference frame -- for example, in a turn, the direction meant by "lateral" or "sideways" would be constantly changing as seen by an observer on the ground, or for that matter, an observer in a balloon drifting by with the airmass. In a turn, by "lateral" we don't mean the "centripetal" direction-- rather we specifically mean "sideways toward the wall of the cockpit". In other words, the direction that is parallel to the aircraft's wingspan. In a coordinated turn, there is definitely a lateral acceleration component, but the aerodynamic force in the lateral direction is zero. In other words, in a coordinated turn, the net lateral acceleration other than that due to gravity is zero. To a first approximation, the only thing that causes an aircraft to experience a lateral acceleration, other than gravity, is the aerodynamic sideforce generated by a sideslip as the airflow strikes the side of the fuselage. That is why the ball serves as a slip-skid indicator, i.e. a sideslip indicator.*** There are some reasons why the ball is not a perfect indicator of sideslip, which will become evident later in this answer, but the idea that the ball is basically a sideslip indicator is a good starting point.
To be complete we should also point out that for a given aerodynamic sideforce, the motion of the ball is also influenced by the G-loading, or more precisely, by the upward aerodynamic force generated by the wing. The higher the "upward" G-loading, the more aerodynamic sideforce it takes to cause a given deflection of the ball. At zero "upward" G's, the slightest aerodynamic sideforce will put the ball all the way into one of the far corners of the glass tube, and at negative "upward" G's, the ball tends to just stay stuck in one of the corners even when sideforce is zero. This is why many aerobatic aircraft have a second slip-skid ball that is mounted upside-down.
If the ball is an accelerometer, how can it be deflected in a situation like a steady-state wing-down slip along a straight-line flight path, where net acceleration is clearly zero? The answer is that net acceleration is zero, but there is still an aerodynamic force component, and therefore an aerodynamically-driven acceleration component, acting in the sideways direction in the aircraft's reference frame, caused by the air impacting the side of the fuselage. Just as a panel-mounted G-meter reads "1" not "0" in straight-and-level flight-- net acceleration is zero, but there is still an aerodynamic force component acting in the upwards direction in the aircraft's reference frame-- the lift force from the wing. Just as the slip-skid ball measures the net lateral (sideways) acceleration other than that caused by gravity, so too does the G-meter measure the net vertical acceleration component other than that caused by gravity, which is essentially just the upward acceleration caused by the wing's lift vector.
What reference frame is the slip-skid ball operating in? We've seen that the slip-skid ball measures lateral acceleration (other than that due to gravity). We can measure net acceleration in any valid inertial reference frame and we'll get the same answer, except for differences due to the tilt of one frame relative to the other. An accelerating airmass is not a valid inertial reference frame. Nor is the aircraft itself, unless net acceleration is zero. Therefore it is not wrong to assert that in the context of an accelerating airmass, the slip-skid ball is operating in the reference frame of the earth, rather than the reference frame of the aircraft or the airmass, except that the reference frame is tilted to match the orientation of the aircraft in space at any given instant in time, and so is constantly changing its orientation with respect to the orientation of the earth's reference frame. In other words the direction called "lateral" is fixed with respect to the aircraft, not the earth-- it changes (relative to the earth) as the aircraft changes heading, or as the aircraft banks. Yet the actual acceleration in that (ever-changing) lateral direction is measured in relation to a valid inertial reference frame, not in relation to the aircraft itself. It is a valid question to ask how it can be that the slip-skid ball which in a sense is tied to the earth reference frame, can give essentially the same indication as the yaw string. Perhaps the above paragraphs have shed some light on those questions-- the answer has to do with the fact that the slip-skid ball is only measuring the lateral component of acceleration, and the fact that the lateral component of acceleration is intimately related to sideslip. Keep in mind that in many instances in this answer, we use phrases like "in the aircraft's own reference frame", but we really only mean to describe the orientation of the reference frame involved. At any instant time, the actual reference frame that an on-board accelerometer such as the G-meter or the slip-skid ball is operating in would indeed be an actual valid inertial reference frame such as that of the earth itself, just tilted differently. It is correct to observe that an accelerometer is not actually operating in the reference frame of the aircraft itself in any case where the aircraft is accelerating, or in the reference frame of the airmass in any case where the wind is not steady. If the slip-skid ball were actually operating in the reference frame of the aircraft itself, it would always read zero, and likewise the G-meter.
In any situation where lateral accelerations can be caused by something other than sideslip, the ball is not perfect as a slip-skid indicator. One example would be any case where the fuselage is streamlined to the relative wind but the rudder is deflected. The sideforce from the rudder itself will move the ball slightly off center opposite to the direction that the pilot would normally expect, i.e. in the same direction as the rudder is deflected. Therefore when using the rudder to streamline the fuselage to the airflow, it is optimum to leave the ball slightly off-center in the direction that it would be deflected if the rudder were not applied at all. Normally this effect is negligible in actual flight, but not always. The scenario of a twin-engine airplane with one failed engine is the best-known case where a pilot will typically actually take this effect into account, leaving the ball significantly deflected in the direction of the pilot's rudder input, i.e. toward the working engine -- see the eighteenth paragraph, and also the footnote, in this related answer for more on this. Of course the sideforce from the rudder will cause a turn unless we cancel it by banking toward the good engine. But fundamentally, the bank is not what is displacing the ball-- for the same rudder input, the ball would show the same displacement regardless of whether the plane was banked as needed to continue in a straight line, or was kept wings-level and allowed to do a flat turn toward the good engine. The yaw string would be centered in either case. (Obviously, if we constrain the flight path to be linear, then everything changes and the slip-skid ball doubles as a bank angle gauge. From this viewpoint, we know we should bank a bit toward the good engine, but the reason why is not obvious.)
The tail rotor of a helicopter also generates an aerodynamic sideforce. Again, just as with the twin-engine airplane with one failed engine, when the fuselage is streamlined to the airflow in forward flight, the slip-skid ball will be slightly off-center, deflected opposite to the direction of the tail rotor's sideforce-- at least in cases where the body of the helicopter tends to tilt along with the disk of the main rotor. If the disk of the main rotor can be tilted to counter the tail rotor's sideforce while the fuselage or body stays completely vertical, then the slip-skid ball can stay centered even when the fuselage or body is completely streamlined to the airflow.
A little-known fact is that it is also possible for the yaw string and slip-skid ball to disagree when an aircraft (glider) is being towed, or when an aircraft (airplane) is towing another aircraft, because the towline can impart a lateral force component whenever the two aircraft are not directly behind each other. In a turn on tow, where the heading of each aircraft is tangent to the circular path of turn, the towline is imparting a lateral force toward the center of the turn on each aircraft, so the ball will be displaced toward the outside when the yaw string is centered.
Note that we will see less deflection of the slip-skid ball for a given deflection of the yaw string when a gust strikes a heavily loaded aircraft, than when it strikes an aircraft of identical shape and size but less mass, travelling at the same airspeed. A much simpler analogy would be two toy cars of the same shape and size but different mass, each with a flag on it. When a wind gust strikes both cars and blows both flags in an identical manner, the wind will accelerate the lighter car faster than the heavier car. The flags are analogous to the yaw string, and the cars are analogous to the aircraft accelerating sideways and tending to "leave the ball behind", so that the ball deflects sideways inside its tube.
Likewise if the pilot uses the rudder to induce a given sideslip angle as measured with the yaw string, the ball will deflect less when an aircraft is heavily loaded than when it is lightly loaded, if the shape and size and speed of travel are all identical. This means that the heavily-loaded aircraft will require less bank angle to travel in a straight line while the pilot is using the rudder to maintain a given sideslip angle, as measured with the yaw string. Or in other words, for a given aircraft travelling at a given airspeed, a given deflection of the ball indicates a larger sideslip angle when the aircraft is heavy than when the aircraft is light. However this is not something that ever needs to be considered in actual for flight for any practical reason-- normally we just keep the ball centered, unless we are using the wing-down (slipping) method of crosswind correction just before touch-down, in which case we bank as needed to allow the desired ground track while keeping the nose aligned with the runway heading.
Obviously on the ground the connection between sideways airflow (sideslip) and lateral acceleration is broken, unless the aircraft is wings-level on a flat icy surface. The wind can blow (creating sideslip) without accelerating the aircraft. Also unless the ground is level, it can push up against the tires in a way that exerts a lateral force component on the aircraft. (Even though the ball doesn't sense the downward acceleration component due to gravity, it does sense the upward accceleration component of the ground pushing up on the tires-- this is why the ball functions as a bubble level when the aircraft is parked and stationary, just as it does in flight whenever net acceleration including gravity is zero.) The question also asked about a roller coaster or train -- there are many situations where the track will exert a lateral force on the vehicle, so a slip-skid ball would not always be centered. Clearly sideslip (sideways wind) has no influence on the slip-skid ball at all in this situation, just as in the case of the aircraft on the ground.
The ball is not quite perfect as a sideways accelerometer. Changes in the rate of yaw rotation about the aircraft's CG can also influence the ball. Imagine that we mounted the aircraft on a pivot at its CG in a vacuum-filled hangar and twirled the airplane like a pinwheel in the yaw dimension. Whenever the yaw rotation rate was increasing, the ball would deflect opposite the direction that the nose was moving. The further the cockpit from the CG, the more pronounced this effect would be.
In other words, a change in yaw rotation rate causes a local lateral acceleration, as measured at some specific point along the length of the fuselage. Also, changes in the rate of pitch rotation change the local G-loading as felt at given points along the length of the fuselage, which changes the indication of the slip-skid ball-- see below for more.
bonus question: if I take a long aircraft (e.g. a AN-225) and put a
ball in several places in the aircraft, will all those indicator
concur in a not coordinated turn?
In a steady-state turn-- meaning constant rates of rotation in pitch and yaw-- then the only apparent centrifugal force induced by the rotation will act in the longitudinal direction, and all the inclinometers will concur, regardless of whether they are centered or not. (Extra detail-- strictly speaking, for this to be true, the inclinometers must all be mounted along the aircraft centerline, so that they are exactly tangent to the arc of movement during a yaw rotation.) Whenever the yaw rotation rate is increasing, inclinometers at the front will be biased toward a deflection toward the outside of the turn and inclinometers at the rear will be biased toward a deflection toward the inside of the turn. Whenever the pitch rotation rate is increasing, the "felt" G-loading will be increased at the front of the aircraft and decreased at the rear of the aircraft, which will tend to bias the inclinometers at the front of the aircraft toward less deflection (in whatever direction they are deflected), and will tend to bias the inclinometers at the rear of the aircraft toward more deflection (in whatever direction they are deflected). Note that as we progressively increase the bank angle, the yaw rotation rate increases and then starts to decrease again, while the pitch rotation rate continually increases. A shallow-banked turn involves mostly yaw rotation, while a steep-banked turn involves mostly pitch rotation. So we can think through how the indications of the inclinometers located at various points along the fuselage will change over time as we progressively increase the bank angle. In short, all the indicators will not always show exactly the same reading.
Normally these effects are negligible in actual flight.
Note that yaw strings mounted at various positions along the fuselage will not show exactly the same deflection during a turn-- the rotation of the aircraft in the yaw axis causes different parts of the aircraft to be moving through the airmass in different directions at any given instant in time. In other words the undisturbed free-stream airflow or "relative wind" is actually curved in a turn. To read about how one pilot takes this into account in actual practice, see the Soaring magazine article Circling the Holghaus way by Richard H. Johnson. Links to some other articles discussing the curvature of the relative wind in turning flight are embedded in this ASE answer.
If you really want to challenge yourself to better understand the behavior of the slip-skid ball, consider the following thought experiments: A) While flying in a moderate to steep turn, the pilot pushes the stick forward hard to unload the wing, or pulls the stick aft hard to load up the wing with extra G's. Obviously the turn rate will vary. Does the slip-skid ball move very much? Does it move at all? Does the yaw string (if present) deflect? B) Imagine a wingover-like maneuver where the aircraft is "unloaded" to less than 1 G while steeply banked, in a (initially) near-level or slightly-climbing pitch attitude. Obviously gravity is accelerating the flight path downwards, and obviously this downward acceleration is largely in the lateral direction in the aircraft's reference frame, at least initially. If the pilot uses the rudder as needed to "help" the vertical fin keep the nose pointing directly into the airflow so that the yaw string stays exactly centered, is the slip-skid ball deflected? Now go do the experiments, ideally in a sailplane or some other aircraft with a yaw string and no propwash over the nose. The latter experiment in particular cannot be done in a useful way with no yaw string-- the aircraft definitely will sideslip if the pilot doesn't use the rudder as needed to prevent it.