Shanks sacrificed his arm on purpose because it was marked by Imu.
He was only able to do this because he genuinely acted to protect Luffy, thereby allowing the Power of Love to bypass Imu's contract restrictions forbidding Shanks from deliberating losing it.