SEOUL/TAIPEI — When Samsung Electronics declared that it would become the world’s top chipmaking foundry, it did so with the confidence that one might expect from South Korea’s largest company. However, three years later, top rival Taiwan Semiconductor Manufacturing Co. has captured a larger market share, prompting Samsung to replace several executives.