Islamic State fighters seized two towns in western Iraq, after besieging hundreds of soldiers, according to a regional official.